diff options
-rw-r--r-- | cli/tests/integration/test_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/doc_only.out | 5 | ||||
-rw-r--r-- | cli/tests/testdata/test/doc_only/mod.ts | 10 | ||||
-rw-r--r-- | cli/tools/test.rs | 4 |
4 files changed, 22 insertions, 3 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 971e756a9..d9d1eed45 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -67,6 +67,12 @@ itest!(doc { output: "test/doc.out", }); +itest!(doc_only { + args: "test --doc --allow-all test/doc_only", + exit_code: 0, + output: "test/doc_only.out", +}); + itest!(markdown { args: "test --doc --allow-all test/markdown.md", exit_code: 1, diff --git a/cli/tests/testdata/test/doc_only.out b/cli/tests/testdata/test/doc_only.out new file mode 100644 index 000000000..c2a91cae7 --- /dev/null +++ b/cli/tests/testdata/test/doc_only.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/test/doc_only/mod.ts$2-5.ts +running 0 tests from [WILDCARD]/test/doc_only/mod.ts + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/testdata/test/doc_only/mod.ts b/cli/tests/testdata/test/doc_only/mod.ts new file mode 100644 index 000000000..467d850a2 --- /dev/null +++ b/cli/tests/testdata/test/doc_only/mod.ts @@ -0,0 +1,10 @@ +/** + * ```ts + * import "./mod.ts"; + * ``` + */ +Deno.test("unreachable", function () { + throw new Error( + "modules that don't end with _test are scanned for documentation tests only should not be executed", + ); +}); diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 62621a232..8111293b4 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -757,9 +757,7 @@ async fn fetch_specifiers_with_test_mode( .fetch(specifier, &mut Permissions::allow_all()) .await?; - if file.media_type != MediaType::Unknown { - *mode = TestMode::Both - } else { + if file.media_type == MediaType::Unknown { *mode = TestMode::Documentation } } |