aboutsummaryrefslogtreecommitdiff
path: root/tests/test_html5lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_html5lib.rs')
-rw-r--r--tests/test_html5lib.rs38
1 files changed, 35 insertions, 3 deletions
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!(