summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-11 18:42:39 +0200
committerMartin Fischer <martin@push-f.com>2023-08-19 06:38:52 +0200
commit900c12ee92ee9dfff7e2c52770ba17a0c51f837f (patch)
treede6c327f36003e561f4e0cea565f626e61f711aa
parentb00714411306ee6500e4ee34a81bd7f4a111169e (diff)
chore: drop test-generator dev-dependency
I want to move the test_html5lib integration test to a separate crate so that it can properly depend on the integration-tests feature in a way so that `cargo test` just works and runs the integration test. (Currently `cargo test` fails since test_html5lib depends on that feature.) However test_html5lib currently depends on the test-generator crate and test-generator doesn't support Cargo workspaces[1] and appears to be unmaintained. This commit therefore drops the test-generator dev-dependency. [1]: https://github.com/frehberg/test-generator/issues/6
-rw-r--r--Cargo.toml2
-rw-r--r--tests/test_html5lib.rs38
2 files changed, 36 insertions, 4 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4bc6b2d..6918f79 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,10 +12,10 @@ 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"
-test-generator = "0.3.0"
[features]
# Feature used by integration tests in tests/ to get access to library internals.
diff --git a/tests/test_html5lib.rs b/tests/test_html5lib.rs
index cda932c..fc5e89c 100644
--- a/tests/test_html5lib.rs
+++ b/tests/test_html5lib.rs
@@ -206,9 +206,41 @@ struct Tests {
tests: Vec<Test>,
}
-#[test_generator::test_resources("tests/html5lib-tests/tokenizer/*.test")]
-fn test_tokenizer_file(resource_name: &str) {
- let path = Path::new(resource_name);
+/// Path to a local checkout of [html5lib-tests], relative to the
+/// 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";
+
+// FUTURE: it would be nice to assert that HTML5LIB_TESTS_PATH matches the path defined in .gitmodules
+// but this is currently blocked by:
+// * Cargo not setting CARGO_WORKSPACE_DIR (see https://github.com/rust-lang/cargo/issues/3946)
+// * gix-config having more dependencies than I'd want to add for this
+
+#[test]
+fn tokenizer() {
+ // TODO: use a custom test harness with e.g. libtest-mimic
+ let test_dir = format!("{HTML5LIB_TESTS_PATH}/tokenizer");
+
+ let mut test_paths = glob::glob(&format!("{test_dir}/*.test"))
+ .unwrap()
+ .peekable();
+
+ if test_paths.peek().is_none() {
+ panic!(
+ "could not find any .test files in {}, maybe try `git submodule update --init`",
+ test_dir
+ );
+ }
+
+ for test_path in test_paths {
+ let test_path = test_path.unwrap();
+
+ test_tokenizer_file(&test_path);
+ }
+}
+
+fn test_tokenizer_file(path: &Path) {
let fname = path.file_name().unwrap().to_str().unwrap();
if matches!(