mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
refactor(runtime): reduce duplication in test harness (#11274)
This commit is contained in:
parent
6a4769670d
commit
c4cc353d59
5 changed files with 52 additions and 60 deletions
|
@ -15,8 +15,8 @@ AssertionError: Test case attempted to exit with exit code: 0
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at [WILDCARD]/$deno$test.js:1:27
|
||||
|
||||
exit(1)
|
||||
|
@ -28,8 +28,8 @@ AssertionError: Test case attempted to exit with exit code: 1
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
exit(2)
|
||||
|
@ -41,8 +41,8 @@ AssertionError: Test case attempted to exit with exit code: 2
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
failures:
|
||||
|
|
|
@ -19,8 +19,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at [WILDCARD]/$deno$test.js:1:27
|
||||
|
||||
test 1
|
||||
|
@ -29,8 +29,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 2
|
||||
|
@ -39,8 +39,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 3
|
||||
|
@ -49,8 +49,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 4
|
||||
|
@ -59,8 +59,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 5
|
||||
|
@ -69,8 +69,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 6
|
||||
|
@ -79,8 +79,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 7
|
||||
|
@ -89,8 +89,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 8
|
||||
|
@ -99,8 +99,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
test 9
|
||||
|
@ -109,8 +109,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at async [WILDCARD]/$deno$test.js:1:1
|
||||
|
||||
failures:
|
||||
|
|
|
@ -10,8 +10,8 @@ Error
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at [WILDCARD]/$deno$test.js:1:27
|
||||
|
||||
failures:
|
||||
|
|
|
@ -11,8 +11,8 @@ Error: fail
|
|||
at asyncOpSanitizer (deno:runtime/js/40_testing.js:35:15)
|
||||
at resourceSanitizer (deno:runtime/js/40_testing.js:72:13)
|
||||
at exitSanitizer (deno:runtime/js/40_testing.js:99:15)
|
||||
at runTest (deno:runtime/js/40_testing.js:218:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:264:13)
|
||||
at runTest (deno:runtime/js/40_testing.js:206:13)
|
||||
at Object.runTests (deno:runtime/js/40_testing.js:249:28)
|
||||
at [WILDCARD]/$deno$test.js:1:27
|
||||
|
||||
failures:
|
||||
|
|
|
@ -191,48 +191,23 @@ finishing test case.`;
|
|||
core.opSync("op_restore_test_permissions", token);
|
||||
}
|
||||
|
||||
async function runTest({ name, ignore, fn, permissions }) {
|
||||
async function runTest({ ignore, fn, permissions }) {
|
||||
let token = null;
|
||||
const time = DateNow();
|
||||
|
||||
try {
|
||||
postTestMessage("wait", {
|
||||
name,
|
||||
});
|
||||
|
||||
if (permissions) {
|
||||
token = pledgeTestPermissions(permissions);
|
||||
}
|
||||
|
||||
if (ignore) {
|
||||
const duration = DateNow() - time;
|
||||
postTestMessage("result", {
|
||||
name,
|
||||
duration,
|
||||
result: "ignored",
|
||||
});
|
||||
|
||||
return;
|
||||
return "ignored";
|
||||
}
|
||||
|
||||
await fn();
|
||||
|
||||
const duration = DateNow() - time;
|
||||
postTestMessage("result", {
|
||||
name,
|
||||
duration,
|
||||
result: "ok",
|
||||
});
|
||||
return "ok";
|
||||
} catch (error) {
|
||||
const duration = DateNow() - time;
|
||||
|
||||
postTestMessage("result", {
|
||||
name,
|
||||
duration,
|
||||
result: {
|
||||
"failed": inspectArgs([error]),
|
||||
},
|
||||
});
|
||||
return { "failed": inspectArgs([error]) };
|
||||
} finally {
|
||||
if (token) {
|
||||
restoreTestPermissions(token);
|
||||
|
@ -261,7 +236,24 @@ finishing test case.`;
|
|||
});
|
||||
|
||||
for (const test of pending) {
|
||||
await runTest(test);
|
||||
const {
|
||||
name,
|
||||
} = test;
|
||||
|
||||
const earlier = DateNow();
|
||||
|
||||
postTestMessage("wait", {
|
||||
name,
|
||||
});
|
||||
|
||||
const result = await runTest(test);
|
||||
const duration = DateNow() - earlier;
|
||||
|
||||
postTestMessage("result", {
|
||||
name,
|
||||
result,
|
||||
duration,
|
||||
});
|
||||
}
|
||||
|
||||
if (disableLog) {
|
||||
|
|
Loading…
Reference in a new issue