summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/ops_sanitizer_missing_details.out20
-rw-r--r--cli/tests/testdata/test/ops_sanitizer_missing_details.ts10
-rw-r--r--runtime/js/40_testing.js7
4 files changed, 41 insertions, 2 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index f3cf9ebd0..9c1ad3f47 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -180,6 +180,12 @@ itest!(ops_sanitizer_multiple_timeout_tests_no_trace {
output: "test/ops_sanitizer_multiple_timeout_tests_no_trace.out",
});
+itest!(ops_sanitizer_missing_details {
+ args: "test --allow-write --allow-read test/ops_sanitizer_missing_details.ts",
+ exit_code: 1,
+ output: "test/ops_sanitizer_missing_details.out",
+});
+
itest!(ops_sanitizer_nexttick {
args: "test test/ops_sanitizer_nexttick.ts",
output: "test/ops_sanitizer_nexttick.out",
diff --git a/cli/tests/testdata/test/ops_sanitizer_missing_details.out b/cli/tests/testdata/test/ops_sanitizer_missing_details.out
new file mode 100644
index 000000000..a6845e190
--- /dev/null
+++ b/cli/tests/testdata/test/ops_sanitizer_missing_details.out
@@ -0,0 +1,20 @@
+Check [WILDCARD]test/ops_sanitizer_missing_details.ts
+running 1 test from [WILDCARD]test/ops_sanitizer_missing_details.ts
+test test 1 ... FAILED [WILDCARD]
+
+failures:
+
+test 1
+Test case is leaking async ops.
+
+- 1 async operation to op_write was started in this test, but never completed.
+
+To get more details where ops were leaked, run again with --trace-ops flag.
+
+failures:
+
+ test 1
+
+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/ops_sanitizer_missing_details.ts b/cli/tests/testdata/test/ops_sanitizer_missing_details.ts
new file mode 100644
index 000000000..406773129
--- /dev/null
+++ b/cli/tests/testdata/test/ops_sanitizer_missing_details.ts
@@ -0,0 +1,10 @@
+// https://github.com/denoland/deno/issues/13729
+// https://github.com/denoland/deno/issues/13938
+import { writeAll } from "../../../../test_util/std/io/util.ts";
+
+Deno.test("test 1", { permissions: { write: true, read: true } }, async () => {
+ const tmpFile = await Deno.makeTempFile();
+ const file = await Deno.open(tmpFile, { write: true });
+ const buf = new Uint8Array(new Array(1_000_000).fill(1));
+ writeAll(file, buf);
+});
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index 2ec60ca44..2c2b55d56 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -173,13 +173,16 @@
preOp.opsCompletedAsync;
if (dispatchedDiff > completedDiff) {
- const [name, hint] = OP_DETAILS[key];
+ const [name, hint] = OP_DETAILS[key] || [key, null];
const count = dispatchedDiff - completedDiff;
let message = `${count} async operation${
count === 1 ? "" : "s"
} to ${name} ${
count === 1 ? "was" : "were"
- } started in this test, but never completed. This is often caused by not ${hint}.`;
+ } started in this test, but never completed.`;
+ if (hint) {
+ message += ` This is often caused by not ${hint}.`;
+ }
const traces = [];
for (const [id, { opName, stack }] of postTraces) {
if (opName !== key) continue;