aboutsummaryrefslogtreecommitdiff
path: root/tests
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 /tests
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
Diffstat (limited to 'tests')
-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!(