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

Use testdata everywhere #311

Merged
merged 5 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion components/datetime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ icu-data-provider = { path = "../data-provider" }
[dev-dependencies]
criterion = "0.3"
icu-data-provider = { path = "../data-provider", features = ["invariant"] }
icu-fs-data-provider = { path = "../fs-data-provider" }
icu-testdata = { path = "../../resources/testdata" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

Expand Down
4 changes: 1 addition & 3 deletions components/datetime/benches/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use std::fmt::Write;

use icu_datetime::DateTimeFormat;
use icu_datetime::MockDateTime;
use icu_fs_data_provider::FsDataProvider;

fn datetime_benches(c: &mut Criterion) {
let fxs = fixtures::get_fixture("styles").unwrap();

let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x")
.expect("Loading file from testdata directory");
let provider = icu_testdata::get_provider();

{
let mut group = c.benchmark_group("datetime");
Expand Down
24 changes: 12 additions & 12 deletions components/datetime/benches/fixtures/tests/styles.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"setups": [
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "full",
Expand All @@ -11,7 +11,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "long",
Expand All @@ -20,7 +20,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "medium",
Expand All @@ -29,7 +29,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "short",
Expand All @@ -38,7 +38,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": null,
Expand All @@ -47,7 +47,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": null,
Expand All @@ -56,7 +56,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": null,
Expand All @@ -65,7 +65,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": null,
Expand All @@ -74,7 +74,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "full",
Expand All @@ -83,7 +83,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "long",
Expand All @@ -92,7 +92,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "medium",
Expand All @@ -101,7 +101,7 @@
}
},
{
"locale": "pl",
"locale": "be",
"options": {
"style": {
"date": "short",
Expand Down
4 changes: 1 addition & 3 deletions components/datetime/examples/work_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// from a work log into human readable dates and times.
use icu_datetime::date::MockDateTime;
use icu_datetime::{options::style, DateTimeFormat};
use icu_fs_data_provider::FsDataProvider;
use icu_locale::LanguageIdentifier;

const DATES_ISO: &[&str] = &[
Expand Down Expand Up @@ -30,8 +29,7 @@ fn print(_input: &str, _value: Option<usize>) {
fn main() {
let langid: LanguageIdentifier = "en".parse().expect("Failed to parse Language Identifier.");

let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x")
.expect("Loading file from testdata directory");
let provider = icu_testdata::get_provider();

let dates = DATES_ISO
.iter()
Expand Down
4 changes: 1 addition & 3 deletions components/datetime/tests/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ mod fixtures;

use icu_datetime::DateTimeFormat;
use icu_datetime::MockDateTime;
use icu_fs_data_provider::FsDataProvider;
use std::fmt::Write;

#[test]
fn test_fixtures() {
let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x")
.expect("Loading file from testdata directory");
let provider = icu_testdata::get_provider();

for fx in fixtures::get_fixture("styles").unwrap().0 {
let langid = fx.input.locale.parse().unwrap();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions components/datetime/tests/fixtures/data/icu4x/manifest.json

This file was deleted.

4 changes: 2 additions & 2 deletions components/datetime/tests/fixtures/tests/styles.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
{
"input": {
"locale": "pl",
"locale": "be",
"value": "2020-03-21T08:25:07.000",
"options": {
"style": {
Expand All @@ -101,7 +101,7 @@
}
},
"output": {
"value": "sobota, 21 marca 2020 08:25:07 zzzz"
"value": "субота, 21 сакавіка 2020 'г'. 'у' 08:25:07, zzzz"
}
}
]
3 changes: 1 addition & 2 deletions components/fs-data-provider/tests/test_file_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::borrow::Cow;

#[test]
fn test_read_json() {
let provider = FsDataProvider::try_new("tests/testdata/json_plurals_37")
.expect("Loading file from testdata directory");
let provider = FsDataProvider::try_new("../../resources/testdata/data/json")
let response = provider
.load(&DataRequest {
data_key: icu_data_key!(plurals: cardinal@1),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions components/icu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
//! ```
//! use icu::locale::LanguageIdentifier;
//! use icu::datetime::{DateTimeFormat, date::MockDateTime, options::style};
//! use icu_fs_data_provider::FsDataProvider;
//!
//! let provider = FsDataProvider::try_new("./tests/fixtures/data/icu4x")
//! .expect("Loading file from testdata directory");
//! let provider = icu_testdata::get_provider();
//!
//! let langid: LanguageIdentifier = "en".parse()
//! .expect("Failed to parse a Language Identifier.");
Expand Down
2 changes: 1 addition & 1 deletion components/pluralrules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = {version = "1.0" }
icu-locale = { path = "../locale", features = ["serde"] }
icu-data-provider = { path = "../data-provider", features = ["invariant"] }
icu-fs-data-provider = { path = "../fs-data-provider" }
icu-testdata = { path = "../../resources/testdata" }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion components/pluralrules/benches/fixtures/plurals.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"langs": ["uk", "de", "sk", "ar", "fr", "it", "en", "cs", "es", "zh"]
"langs": ["ar", "be", "bn", "en", "es", "fr", "ja", "sr", "th", "tr"]
}
4 changes: 1 addition & 3 deletions components/pluralrules/benches/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ mod helpers;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

use icu_data_provider::{icu_data_key, structs, DataEntry, DataProvider, DataRequest};
use icu_fs_data_provider::FsDataProvider;
use std::borrow::Cow;

fn parser(c: &mut Criterion) {
use icu_pluralrules::rules::parse_condition;

let plurals_data = helpers::get_plurals_data();

let provider = FsDataProvider::try_new("./tests/data/json_plurals_37")
.expect("Loading file from testdata directory");
let provider = icu_testdata::get_provider();

let mut rules = vec![];

Expand Down
4 changes: 1 addition & 3 deletions components/pluralrules/benches/pluralrules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ mod helpers;

use criterion::{criterion_group, criterion_main, Criterion};

use icu_fs_data_provider::FsDataProvider;
use icu_pluralrules::{PluralRuleType, PluralRules};

fn pluralrules(c: &mut Criterion) {
let plurals_data = helpers::get_plurals_data();
let numbers_data = helpers::get_numbers_data();

let provider = FsDataProvider::try_new("./tests/data/json_plurals_37")
.expect("Loading file from testdata directory");
let provider = icu_testdata::get_provider();

c.bench_function("pluralrules/overview", |b| {
b.iter(|| {
Expand Down
Loading