aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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!(