summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/resource_sanitizer.out21
-rw-r--r--cli/tests/testdata/test/resource_sanitizer.ts4
3 files changed, 31 insertions, 0 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index 53dbb07d3..0697fc69c 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -167,6 +167,12 @@ itest!(ops_sanitizer_nexttick {
output: "test/ops_sanitizer_nexttick.out",
});
+itest!(resource_sanitizer {
+ args: "test --allow-read test/resource_sanitizer.ts",
+ exit_code: 1,
+ output: "test/resource_sanitizer.out",
+});
+
itest!(exit_sanitizer {
args: "test test/exit_sanitizer.ts",
output: "test/exit_sanitizer.out",
diff --git a/cli/tests/testdata/test/resource_sanitizer.out b/cli/tests/testdata/test/resource_sanitizer.out
new file mode 100644
index 000000000..632b75292
--- /dev/null
+++ b/cli/tests/testdata/test/resource_sanitizer.out
@@ -0,0 +1,21 @@
+Check [WILDCARD]/test/resource_sanitizer.ts
+running 1 test from [WILDCARD]/test/resource_sanitizer.ts
+test leak ... FAILED ([WILDCARD])
+
+failures:
+
+leak
+AssertionError: Test case is leaking 2 resources:
+
+ - The stdin pipe (rid 0) was opened before the test started, but was closed during the test. Do not close resources in a test that were not created during that test.
+ - A file (rid 3) was opened during the test, but not closed during the test. Close the file handle by calling `file.close()`.
+
+ at [WILDCARD]
+
+failures:
+
+ leak
+
+test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+error: Test failed
diff --git a/cli/tests/testdata/test/resource_sanitizer.ts b/cli/tests/testdata/test/resource_sanitizer.ts
new file mode 100644
index 000000000..c1291b89a
--- /dev/null
+++ b/cli/tests/testdata/test/resource_sanitizer.ts
@@ -0,0 +1,4 @@
+Deno.test("leak", function () {
+ Deno.openSync("001_hello.js");
+ Deno.stdin.close();
+});