From 8cf694d76e0991b4e24ecdc5d2a88bb74713d9cd Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 16 Oct 2021 08:46:03 +0900 Subject: [PATCH] Extract `phf_macros` tests as a separated crate --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- phf_codegen/test/Cargo.toml | 2 +- phf_macros/Cargo.toml | 5 ----- phf_macros_tests/Cargo.toml | 15 +++++++++++++++ {phf_macros => phf_macros_tests}/benches/bench.rs | 0 phf_macros_tests/src/lib.rs | 1 + .../tests/compile-fail-unicase/equivalent-keys.rs | 2 +- .../compile-fail-unicase/equivalent-keys.stderr | 0 .../tests/compile-fail/bad-syntax.rs | 0 .../tests/compile-fail/bad-syntax.stderr | 0 {phf_macros => phf_macros_tests}/tests/test.rs | 3 +-- .../tests/trybuild.rs | 6 +++++- 13 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 phf_macros_tests/Cargo.toml rename {phf_macros => phf_macros_tests}/benches/bench.rs (100%) create mode 100644 phf_macros_tests/src/lib.rs rename {phf_macros => phf_macros_tests}/tests/compile-fail-unicase/equivalent-keys.rs (89%) rename {phf_macros => phf_macros_tests}/tests/compile-fail-unicase/equivalent-keys.stderr (100%) rename {phf_macros => phf_macros_tests}/tests/compile-fail/bad-syntax.rs (100%) rename {phf_macros => phf_macros_tests}/tests/compile-fail/bad-syntax.stderr (100%) rename {phf_macros => phf_macros_tests}/tests/test.rs (99%) rename phf_macros/tests/compiletest.rs => phf_macros_tests/tests/trybuild.rs (61%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8928defc..f720a391 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,8 +33,8 @@ jobs: - name: phf_macros UI test if: matrix.version == '1.46.0' - working-directory: phf_macros - run: cargo test --features=unicase -- --ignored --test-threads=1 + working-directory: phf_macros_tests + run: cargo test -- --ignored --test-threads=1 - name: phf_codegen test run: cargo test -p phf_codegen_test diff --git a/Cargo.toml b/Cargo.toml index 9db708bf..13b416d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,12 +5,12 @@ members = [ "phf_codegen/test", "phf_generator", "phf_macros", + "phf_macros_tests", "phf_shared" ] [patch.crates-io] phf = { path = "phf" } -phf_codegen = { path = "./phf_codegen" } phf_generator = { path = "./phf_generator" } phf_macros = { path = "./phf_macros" } phf_shared = { path = "./phf_shared" } diff --git a/phf_codegen/test/Cargo.toml b/phf_codegen/test/Cargo.toml index d8397b8d..e9d65264 100644 --- a/phf_codegen/test/Cargo.toml +++ b/phf_codegen/test/Cargo.toml @@ -11,6 +11,6 @@ uncased = { version = "0.9.6", default-features = false } unicase = "2.4.0" [build-dependencies] -phf_codegen = "0.10.0" +phf_codegen = { version = "0.10.0", path = ".." } unicase = "2.4.0" uncased = { version = "0.9.6", default-features = false } diff --git a/phf_macros/Cargo.toml b/phf_macros/Cargo.toml index 474bf8cb..a3454a36 100644 --- a/phf_macros/Cargo.toml +++ b/phf_macros/Cargo.toml @@ -24,8 +24,3 @@ unicase_ = { package = "unicase", version = "2.4.0", optional = true } phf_generator = "0.10.0" phf_shared = { version = "0.10.0", default-features = false } - -[dev-dependencies] -trybuild = "1.0" -phf = { version = "0.10", features = ["macros", "unicase"] } -unicase_ = { package = "unicase", version = "2.4.0" } diff --git a/phf_macros_tests/Cargo.toml b/phf_macros_tests/Cargo.toml new file mode 100644 index 00000000..bc2478c7 --- /dev/null +++ b/phf_macros_tests/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "phf_macros_tests" +version = "0.1.0" +authors = ["Yuki Okushi "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[dev-dependencies] +trybuild = "1.0" +phf = { version = "0.10", features = ["macros"] } +phf_macros = { version = "0.10", features = ["unicase"] } +unicase = "2.4.0" diff --git a/phf_macros/benches/bench.rs b/phf_macros_tests/benches/bench.rs similarity index 100% rename from phf_macros/benches/bench.rs rename to phf_macros_tests/benches/bench.rs diff --git a/phf_macros_tests/src/lib.rs b/phf_macros_tests/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/phf_macros_tests/src/lib.rs @@ -0,0 +1 @@ + diff --git a/phf_macros/tests/compile-fail-unicase/equivalent-keys.rs b/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.rs similarity index 89% rename from phf_macros/tests/compile-fail-unicase/equivalent-keys.rs rename to phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.rs index 7f548c48..3ebcd015 100644 --- a/phf_macros/tests/compile-fail-unicase/equivalent-keys.rs +++ b/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.rs @@ -1,4 +1,4 @@ -use unicase_::UniCase; +use unicase::UniCase; use phf::phf_map; static MAP: phf::Map, isize> = phf_map!( diff --git a/phf_macros/tests/compile-fail-unicase/equivalent-keys.stderr b/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr similarity index 100% rename from phf_macros/tests/compile-fail-unicase/equivalent-keys.stderr rename to phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr diff --git a/phf_macros/tests/compile-fail/bad-syntax.rs b/phf_macros_tests/tests/compile-fail/bad-syntax.rs similarity index 100% rename from phf_macros/tests/compile-fail/bad-syntax.rs rename to phf_macros_tests/tests/compile-fail/bad-syntax.rs diff --git a/phf_macros/tests/compile-fail/bad-syntax.stderr b/phf_macros_tests/tests/compile-fail/bad-syntax.stderr similarity index 100% rename from phf_macros/tests/compile-fail/bad-syntax.stderr rename to phf_macros_tests/tests/compile-fail/bad-syntax.stderr diff --git a/phf_macros/tests/test.rs b/phf_macros_tests/tests/test.rs similarity index 99% rename from phf_macros/tests/test.rs rename to phf_macros_tests/tests/test.rs index d196b733..a10e1a8c 100644 --- a/phf_macros/tests/test.rs +++ b/phf_macros_tests/tests/test.rs @@ -240,10 +240,9 @@ mod map { } } - #[cfg(feature = "unicase")] #[test] fn test_unicase() { - use unicase_::UniCase; + use unicase::UniCase; static MAP: phf::Map, isize> = phf_map!( UniCase::ascii("FOO") => 10, UniCase::unicode("Bar") => 11, diff --git a/phf_macros/tests/compiletest.rs b/phf_macros_tests/tests/trybuild.rs similarity index 61% rename from phf_macros/tests/compiletest.rs rename to phf_macros_tests/tests/trybuild.rs index 7b3c223a..8e80715c 100644 --- a/phf_macros/tests/compiletest.rs +++ b/phf_macros_tests/tests/trybuild.rs @@ -1,5 +1,9 @@ +// The diagnostics may be different between stable and nightly, so +// we mark them as `#[ignore]` and invoke with `--ignored` explicitly +// when testing. + #[test] -#[ignore] // diagnostics may be different between stable and nightly. +#[ignore] fn compile_test_unicase() { let t = trybuild::TestCases::new(); t.compile_fail("tests/compile-fail-unicase/*.rs");