summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-09-01 17:31:56 +0800
committerGitHub <noreply@github.com>2021-09-01 18:31:56 +0900
commit77ead8af20180453aa2d0db67d7856641bd5498f (patch)
treea171be6d325e071b21f5a4718117f9bed12d7eb9
parentc49eee551fdf78ab0230ec30d4537c98dd5d0c80 (diff)
fix(cli): retain path based test mode inference (#11878)
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/doc_only.out5
-rw-r--r--cli/tests/testdata/test/doc_only/mod.ts10
-rw-r--r--cli/tools/test.rs4
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
}
}