Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run snapshot tests dynamically in unimarkup-core crate #105

Merged
merged 14 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"parser",
"render",
]
resolver = "2"
nfejzic marked this conversation as resolved.
Show resolved Hide resolved

# Compile snapshot testing library "insta" with "release" flag so that it runs
# faster
Expand Down
8 changes: 3 additions & 5 deletions commons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
once_cell = { workspace = true, optional = true }
icu = "=1.2.0"
zerovec = "0.9.4"
icu_provider = "=1.2.0"
icu_provider_adapters = "=1.2.0"
icu_segmenter = "1.3.0"
icu_locid = "1.3.0"
regex = { version = "1.8.1", optional = true }
insta = {version = "1.29.0", features = ["serde"], optional = true}
insta = { version = "1.29.0", features = ["serde"], optional = true }

[features]
test_runner = ["dep:regex", "dep:once_cell", "dep:insta"]
4 changes: 2 additions & 2 deletions commons/src/config/locale.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod serde {
use icu::locid::Locale;
use icu_locid::Locale;
use serde::{Deserialize, Deserializer, Serializer};

pub mod single {
Expand Down Expand Up @@ -70,7 +70,7 @@ pub mod serde {
}

pub mod clap {
pub fn parse_locale(input: &str) -> Result<icu::locid::Locale, clap::Error> {
pub fn parse_locale(input: &str) -> Result<icu_locid::Locale, clap::Error> {
input.parse().map_err(|err| {
clap::Error::raw(
clap::error::ErrorKind::InvalidValue,
Expand Down
8 changes: 4 additions & 4 deletions commons/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{collections::HashSet, path::PathBuf};

use clap::{crate_authors, Args, Parser};
use clap::{Args, Parser};
use logid::err;
use serde::{Deserialize, Serialize};

use self::{log_id::ConfigErr, output::Output, preamble::Preamble};

pub use icu::locid;
pub use icu_locid;

pub mod locale;
pub mod log_id;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub trait ConfigFns {
}

#[derive(Parser, Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[command(name = UNIMARKUP_NAME, help_template = HELP_TEMPLATE, author = crate_authors!(", "), version, about = ABOUT, long_about = None)]
#[command(name = UNIMARKUP_NAME, help_template = HELP_TEMPLATE, author, version, about = ABOUT, long_about = None)]
pub struct Config {
#[command(flatten)]
pub preamble: Preamble,
Expand Down Expand Up @@ -112,7 +112,7 @@ where
format!("HashSet conversion failed with: {:?}", err),
)
});
Ok(HashSet::from_iter(entries?.into_iter()))
Ok(HashSet::from_iter(entries?))
}

// Define extension trait
Expand Down
18 changes: 9 additions & 9 deletions commons/src/config/preamble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use clap::Args;
use icu::locid::Locale;
use icu_locid::Locale;
use logid::err;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -55,7 +55,7 @@ pub struct I18n {

impl ConfigFns for I18n {
fn merge(&mut self, other: Self) {
self.output_langs.extend(other.output_langs.into_iter());
self.output_langs.extend(other.output_langs);
}

fn validate(&self) -> Result<(), ConfigErr> {
Expand All @@ -79,8 +79,8 @@ pub struct RenderConfig {

impl ConfigFns for RenderConfig {
fn merge(&mut self, other: Self) {
self.ignore.extend(other.ignore.into_iter());
self.parameter.extend(other.parameter.into_iter());
self.ignore.extend(other.ignore);
self.parameter.extend(other.parameter);
}

fn validate(&self) -> Result<(), ConfigErr> {
Expand All @@ -103,7 +103,7 @@ pub struct Citedata {
impl ConfigFns for Citedata {
fn merge(&mut self, other: Self) {
self.style.replace_none(other.style);
self.references.extend(other.references.into_iter());
self.references.extend(other.references);
}

fn validate(&self) -> Result<(), ConfigErr> {
Expand Down Expand Up @@ -146,8 +146,8 @@ pub struct Metadata {
impl ConfigFns for Metadata {
fn merge(&mut self, other: Self) {
self.title.replace_none(other.title);
self.authors.extend(other.authors.into_iter());
self.fonts.extend(other.fonts.into_iter());
self.authors.extend(other.authors);
self.fonts.extend(other.fonts);

// Note: `base` and `description` must not be merged with sub-configs according to specification.
}
Expand Down Expand Up @@ -184,8 +184,8 @@ pub struct HtmlSpecificParameter {

impl ConfigFns for HtmlSpecificParameter {
fn merge(&mut self, other: Self) {
self.favicons.extend(other.favicons.into_iter());
self.keywords.extend(other.keywords.into_iter());
self.favicons.extend(other.favicons);
self.keywords.extend(other.keywords);
}

fn validate(&self) -> Result<(), ConfigErr> {
Expand Down
2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/any.rs

This file was deleted.

2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/fallback/likelysubtags_v1/mod.rs

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/fallback/mod.rs

This file was deleted.

2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/fallback/parents_v1/mod.rs

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/fallback/supplement/co_v1/mod.rs

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions commons/src/scanner/icu_data/fallback/supplement/mod.rs

This file was deleted.

Loading
Loading