diff options
author | Martin Fischer <martin@push-f.com> | 2023-08-11 19:37:09 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-08-19 06:39:08 +0200 |
commit | b48e5c3b99fd537d223cb899e8675177d77e650c (patch) | |
tree | d614c5c0950f75d677fb5e9e351c19a30d140257 | |
parent | 900c12ee92ee9dfff7e2c52770ba17a0c51f837f (diff) |
refactor: move html5lib test to own crate to fix `cargo test`
Previously `cargo test` failed because it ran the test_html5lib
integration test, which depends on the integration-tests feature
(so you always had to run `cargo test` with
`--features integration-tests` or `--all-features`, which was annoying).
This commit moves the integration tests to another crate,
so that the dependency on the feature can be properly defined
in a way so that `cargo test` just works and runs the test.
-rw-r--r-- | .gitmodules | 4 | ||||
-rw-r--r-- | Cargo.toml | 8 | ||||
-rw-r--r-- | integration_tests/Cargo.toml | 22 | ||||
m--------- | integration_tests/html5lib-tests (renamed from tests/html5lib-tests) | 0 | ||||
-rw-r--r-- | integration_tests/tests/test_html5lib.rs (renamed from tests/test_html5lib.rs) | 7 |
5 files changed, 29 insertions, 12 deletions
diff --git a/.gitmodules b/.gitmodules index 2411bd3..36e58a2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "tests/html5lib-tests"] - path = tests/html5lib-tests +[submodule "html5lib-tests"] + path = integration_tests/html5lib-tests url = https://github.com/html5lib/html5lib-tests @@ -1,3 +1,7 @@ +[workspace] +members = [".", "integration_tests"] +default-members = [".", "integration_tests"] + [package] name = "html5tokenizer" authors = ["Markus Unterwaditzer <markus-honeypot@unterwaditzer.net>", "Martin Fischer <martin@push-f.com>"] @@ -12,10 +16,6 @@ include = ["src/**/*", "LICENSE", "README.md"] [dev-dependencies] codespan-reporting = "0.11.1" -glob = "0.3.1" -pretty_assertions = "1.0.0" -serde = { version = "1.0.130", features = ["derive"] } -serde_json = "1.0.71" [features] # Feature used by integration tests in tests/ to get access to library internals. diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml new file mode 100644 index 0000000..1e68a0b --- /dev/null +++ b/integration_tests/Cargo.toml @@ -0,0 +1,22 @@ +# The html5lib integration test lives in a separate crate because +# we want `cargo test` to run these tests despite their dependency +# on the `integration-tests` feature from the html5tokenizer crate +# and cargo doesn't support features to be automatically enabled for +# integration tests in a single crate. (required-features under [[test]] +# just results in the test being skipped if the feature isn't enabled). +# See https://github.com/rust-lang/cargo/issues/2911#issuecomment-524652568. + +[package] +name = "integration_tests" +publish = false +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dev-dependencies] +glob = "0.3.1" +html5tokenizer = { path = "..", features = ["integration-tests"] } +pretty_assertions = "1.0.0" +serde = { version = "1.0.130", features = ["derive"] } +serde_json = "1.0.71" diff --git a/tests/html5lib-tests b/integration_tests/html5lib-tests -Subproject 6030cb6e40a0cf68ae38bf0001bb85b727b80a2 +Subproject 6030cb6e40a0cf68ae38bf0001bb85b727b80a2 diff --git a/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs index fc5e89c..cf95bb6 100644 --- a/tests/test_html5lib.rs +++ b/integration_tests/tests/test_html5lib.rs @@ -5,11 +5,6 @@ use pretty_assertions::assert_eq; use serde::{de::Error as _, Deserialize}; use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path}; -#[cfg(not(feature = "integration-tests"))] -compile_error!( - "integration tests need the integration-tests feature enabled. Run cargo test --all-features" -); - struct ExpectedOutputTokens(Vec<Token<()>>); impl<'de> Deserialize<'de> for ExpectedOutputTokens { @@ -210,7 +205,7 @@ struct Tests { /// directory containing the `Cargo.toml` file of the current crate. /// /// [html5lib-tests]: https://github.com/html5lib/html5lib-tests -const HTML5LIB_TESTS_PATH: &str = "tests/html5lib-tests"; +const HTML5LIB_TESTS_PATH: &str = "html5lib-tests"; // FUTURE: it would be nice to assert that HTML5LIB_TESTS_PATH matches the path defined in .gitmodules // but this is currently blocked by: |