summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.ns.d.ts4
-rw-r--r--cli/tests/exit_sanitizer_test.out28
-rw-r--r--cli/tests/exit_sanitizer_test.ts11
-rw-r--r--cli/tests/integration_tests.rs6
-rw-r--r--cli/tests/test_finally_cleartimeout.out8
5 files changed, 50 insertions, 7 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 04bf8ad80..1627843e4 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -108,6 +108,10 @@ declare namespace Deno {
* after the test has exactly the same contents as before the test. Defaults
* to true. */
sanitizeResources?: boolean;
+
+ /** Ensure the test case does not prematurely cause the process to exit,
+ * for example via a call to `Deno.exit`. Defaults to true. */
+ sanitizeExit?: boolean;
}
/** Register a test which will be run when `deno test` is used on the command
diff --git a/cli/tests/exit_sanitizer_test.out b/cli/tests/exit_sanitizer_test.out
new file mode 100644
index 000000000..351453928
--- /dev/null
+++ b/cli/tests/exit_sanitizer_test.out
@@ -0,0 +1,28 @@
+Check [WILDCARD]/$deno$test.ts
+running 3 tests
+test exit(0) ... FAILED ([WILDCARD])
+test exit(1) ... FAILED ([WILDCARD])
+test exit(2) ... FAILED ([WILDCARD])
+
+failures:
+
+exit(0)
+AssertionError: Test case attempted to exit with exit code: 0
+ [WILDCARD]
+
+exit(1)
+AssertionError: Test case attempted to exit with exit code: 1
+ [WILDCARD]
+
+exit(2)
+AssertionError: Test case attempted to exit with exit code: 2
+ [WILDCARD]
+
+failures:
+
+ exit(0)
+ exit(1)
+ exit(2)
+
+test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
diff --git a/cli/tests/exit_sanitizer_test.ts b/cli/tests/exit_sanitizer_test.ts
new file mode 100644
index 000000000..186406a9d
--- /dev/null
+++ b/cli/tests/exit_sanitizer_test.ts
@@ -0,0 +1,11 @@
+Deno.test("exit(0)", function () {
+ Deno.exit(0);
+});
+
+Deno.test("exit(1)", function () {
+ Deno.exit(1);
+});
+
+Deno.test("exit(2)", function () {
+ Deno.exit(2);
+});
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index d47c8d1e9..78cecf2fb 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2252,6 +2252,12 @@ mod integration {
assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out"));
}
+ itest!(test_exit_sanitizer {
+ args: "test exit_sanitizer_test.ts",
+ output: "exit_sanitizer_test.out",
+ exit_code: 1,
+ });
+
itest!(stdout_write_all {
args: "run --quiet stdout_write_all.ts",
output: "stdout_write_all.out",
diff --git a/cli/tests/test_finally_cleartimeout.out b/cli/tests/test_finally_cleartimeout.out
index c8f412bf0..c88b8242b 100644
--- a/cli/tests/test_finally_cleartimeout.out
+++ b/cli/tests/test_finally_cleartimeout.out
@@ -7,13 +7,7 @@ failures:
error
Error: fail
- at [WILDCARD]/test_finally_cleartimeout.ts:4:11
- at asyncOpSanitizer (deno:runtime/js/40_testing.js:38:15)
- at Object.resourceSanitizer [as fn] (deno:runtime/js/40_testing.js:74:13)
- at TestRunner.[Symbol.asyncIterator] (deno:runtime/js/40_testing.js:249:24)
- at AsyncGenerator.next (<anonymous>)
- at Object.runTests (deno:runtime/js/40_testing.js:326:22)
- at async [WILDCARD]/$deno$test.ts:3:1
+ [WILDCARD]
failures: