Skip to content

Add "opt-out" test gating for vendors, document getting working tests #44

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

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ sudo: false
script:
- cargo build --verbose
- cargo test --verbose
- cargo package
- cd target/package/unicode-normalization-*
- RUSTFLAGS="--cfg minimal_tests" cargo test --verbose
notifications:
email:
on_success: never
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Decomposition and Recomposition, as described in
Unicode Standard Annex #15.
"""

exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "src/normalization_tests.rs", "src/test.rs" ]
exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "src/normalization_tests.rs" ]

[dependencies]
smallvec = "0.6"
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,26 @@ to your `Cargo.toml`:
[dependencies]
unicode-normalization = "0.1.8"
```

## Linux Vendors / Downstream
As is, tests won't work on the published crate, as important
corpus data required for fully testing functionality otherwise
bloats the size of the crate.

Tests aren't hugely meaningful without this, but there are two
workarounds:

```bash
RUSTFLAGS="--cfg minimal_tests" cargo test
```

This will make the crate compile, and some arbitrary set of lower
quality tests pass.

```bash
python scripts/unicode.py
cp ./normalization_tests.rs src/
```

This will generate the full corpus required for tests to work,
without needing to pass any special flags.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod tables;

#[cfg(test)]
mod test;
#[cfg(test)]
#[cfg(all(test,not(minimal_tests)))]
mod normalization_tests;

/// Methods for composing and decomposing characters.
Expand Down
2 changes: 2 additions & 0 deletions src/stream_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ mod tests {
classify_nonstarters,
};
use std::char;
#[cfg(not(minimal_tests))]
use normalization_tests::NORMALIZATION_TESTS;
use normalize::decompose_compatible;
use lookups::canonical_combining_class;
Expand All @@ -119,6 +120,7 @@ mod tests {
StreamSafe::new(s.chars()).collect()
}

#[cfg(not(minimal_tests))]
#[test]
fn test_normalization_tests_unaffected() {
for test in NORMALIZATION_TESTS {
Expand Down
3 changes: 2 additions & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fn test_nfkc() {
t!("a\u{300}\u{305}\u{315}\u{5ae}b", "\u{e0}\u{5ae}\u{305}\u{315}b");
}

#[cfg(not(minimal_tests))]
#[test]
fn test_official() {
use normalization_tests::NORMALIZATION_TESTS;
Expand Down Expand Up @@ -158,7 +159,7 @@ fn test_official() {
}
}
}

#[cfg(not(minimal_tests))]
#[test]
fn test_quick_check() {
use normalization_tests::NORMALIZATION_TESTS;
Expand Down