mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 03:44:05 -05:00
feat: provide ops details for ops sanitizer failures (#12188)
This commit is contained in:
parent
3b2cb8e711
commit
1683044ed9
4 changed files with 78 additions and 4 deletions
|
@ -133,6 +133,12 @@ itest!(allow_none {
|
||||||
output: "test/allow_none.out",
|
output: "test/allow_none.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(ops_sanitizer_unstable {
|
||||||
|
args: "test --unstable test/ops_sanitizer_unstable.ts",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "test/ops_sanitizer_unstable.out",
|
||||||
|
});
|
||||||
|
|
||||||
itest!(exit_sanitizer {
|
itest!(exit_sanitizer {
|
||||||
args: "test test/exit_sanitizer.ts",
|
args: "test test/exit_sanitizer.ts",
|
||||||
output: "test/exit_sanitizer.out",
|
output: "test/exit_sanitizer.out",
|
||||||
|
|
35
cli/tests/testdata/test/ops_sanitizer_unstable.out
vendored
Normal file
35
cli/tests/testdata/test/ops_sanitizer_unstable.out
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
Check [WILDCARD]/testdata/test/ops_sanitizer_unstable.ts
|
||||||
|
running 2 tests from [WILDCARD]/testdata/test/ops_sanitizer_unstable.ts
|
||||||
|
test no-op ... ok ([WILDCARD])
|
||||||
|
test leak interval ... FAILED ([WILDCARD])
|
||||||
|
|
||||||
|
failures:
|
||||||
|
|
||||||
|
leak interval
|
||||||
|
AssertionError: Test case is leaking async ops.
|
||||||
|
Before:
|
||||||
|
- dispatched: 1
|
||||||
|
- completed: 1
|
||||||
|
After:
|
||||||
|
- dispatched: 3
|
||||||
|
- completed: 2
|
||||||
|
Ops:
|
||||||
|
op_global_timer:
|
||||||
|
Before:
|
||||||
|
- dispatched: 1
|
||||||
|
- completed: 1
|
||||||
|
After:
|
||||||
|
- dispatched: 3
|
||||||
|
- completed: 2
|
||||||
|
|
||||||
|
Make sure to await all promises returned from Deno APIs before
|
||||||
|
finishing test case.
|
||||||
|
at [WILDCARD]
|
||||||
|
|
||||||
|
failures:
|
||||||
|
|
||||||
|
leak interval
|
||||||
|
|
||||||
|
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
|
||||||
|
|
||||||
|
error: Test failed
|
4
cli/tests/testdata/test/ops_sanitizer_unstable.ts
vendored
Normal file
4
cli/tests/testdata/test/ops_sanitizer_unstable.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Deno.test("no-op", function () {});
|
||||||
|
Deno.test("leak interval", function () {
|
||||||
|
setInterval(function () {});
|
||||||
|
});
|
|
@ -23,6 +23,7 @@
|
||||||
StringPrototypeIncludes,
|
StringPrototypeIncludes,
|
||||||
StringPrototypeSlice,
|
StringPrototypeSlice,
|
||||||
RegExp,
|
RegExp,
|
||||||
|
Number,
|
||||||
RegExpPrototypeTest,
|
RegExpPrototypeTest,
|
||||||
SymbolToStringTag,
|
SymbolToStringTag,
|
||||||
} = window.__bootstrap.primordials;
|
} = window.__bootstrap.primordials;
|
||||||
|
@ -46,22 +47,50 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const post = metrics();
|
const post = metrics();
|
||||||
|
|
||||||
// We're checking diff because one might spawn HTTP server in the background
|
// We're checking diff because one might spawn HTTP server in the background
|
||||||
// that will be a pending async op before test starts.
|
// that will be a pending async op before test starts.
|
||||||
const dispatchedDiff = post.opsDispatchedAsync - pre.opsDispatchedAsync;
|
const dispatchedDiff = post.opsDispatchedAsync - pre.opsDispatchedAsync;
|
||||||
const completedDiff = post.opsCompletedAsync - pre.opsCompletedAsync;
|
const completedDiff = post.opsCompletedAsync - pre.opsCompletedAsync;
|
||||||
assert(
|
|
||||||
dispatchedDiff === completedDiff,
|
const details = [];
|
||||||
`Test case is leaking async ops.
|
for (const key in post.ops) {
|
||||||
|
const dispatchedDiff = Number(
|
||||||
|
post.ops[key]?.opsDispatchedAsync -
|
||||||
|
(pre.ops[key]?.opsDispatchedAsync ?? 0),
|
||||||
|
);
|
||||||
|
const completedDiff = Number(
|
||||||
|
post.ops[key]?.opsCompletedAsync -
|
||||||
|
(pre.ops[key]?.opsCompletedAsync ?? 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (dispatchedDiff !== completedDiff) {
|
||||||
|
details.push(`
|
||||||
|
${key}:
|
||||||
|
Before:
|
||||||
|
- dispatched: ${pre.ops[key]?.opsDispatchedAsync ?? 0}
|
||||||
|
- completed: ${pre.ops[key]?.opsCompletedAsync ?? 0}
|
||||||
|
After:
|
||||||
|
- dispatched: ${post.ops[key].opsDispatchedAsync}
|
||||||
|
- completed: ${post.ops[key].opsCompletedAsync}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = `Test case is leaking async ops.
|
||||||
Before:
|
Before:
|
||||||
- dispatched: ${pre.opsDispatchedAsync}
|
- dispatched: ${pre.opsDispatchedAsync}
|
||||||
- completed: ${pre.opsCompletedAsync}
|
- completed: ${pre.opsCompletedAsync}
|
||||||
After:
|
After:
|
||||||
- dispatched: ${post.opsDispatchedAsync}
|
- dispatched: ${post.opsDispatchedAsync}
|
||||||
- completed: ${post.opsCompletedAsync}
|
- completed: ${post.opsCompletedAsync}
|
||||||
|
${details.length > 0 ? "Ops:" + details.join("") : ""}
|
||||||
|
|
||||||
Make sure to await all promises returned from Deno APIs before
|
Make sure to await all promises returned from Deno APIs before
|
||||||
finishing test case.`,
|
finishing test case.`;
|
||||||
|
|
||||||
|
assert(
|
||||||
|
dispatchedDiff === completedDiff,
|
||||||
|
message,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue