-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
test_runner: call abort on test finish #48827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
21a9e6d
0ed4cb4
c4710a8
eeabcf5
f93f38e
5017fe5
58da4d2
f5f36b6
0c7c812
42f7308
976b24f
e511f95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const {test, afterEach} = require('node:test'); | ||
const assert = require('node:assert'); | ||
const { waitForAbort } = require('./wait-for-abort-helper'); | ||
|
||
let testCount = 0; | ||
let signal; | ||
|
||
afterEach(() => { | ||
assert.equal(signal.aborted, false); | ||
|
||
waitForAbort({ testNumber: ++testCount, signal }); | ||
}); | ||
|
||
test("sync", (t) => { | ||
signal = t.signal; | ||
assert.equal(signal.aborted, false); | ||
throw new Error('failing the sync test'); | ||
}); | ||
|
||
test("async", async (t) => { | ||
await null; | ||
signal = t.signal; | ||
assert.equal(signal.aborted, false); | ||
throw new Error('failing the async test'); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {test, afterEach} = require('node:test'); | ||
const assert = require('node:assert'); | ||
const {waitForAbort} = require("./wait-for-abort-helper"); | ||
|
||
let testCount = 0; | ||
let signal; | ||
|
||
afterEach(() => { | ||
assert.equal(signal.aborted, false); | ||
|
||
waitForAbort({ testNumber: ++testCount, signal }); | ||
}); | ||
|
||
test("sync", (t) => { | ||
signal = t.signal; | ||
assert.equal(signal.aborted, false); | ||
}); | ||
|
||
test("async", async (t) => { | ||
await null; | ||
signal = t.signal; | ||
assert.equal(signal.aborted, false); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
module.exports = { | ||||||
waitForAbort: function ({ testNumber, signal }) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we wait for the node/lib/internal/test_runner/test.js Lines 589 to 590 in f5f36b6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so doing await will always fail... |
||||||
let retries = 0; | ||||||
|
||||||
const interval = setInterval(() => { | ||||||
retries++; | ||||||
if(signal.aborted) { | ||||||
console.log(`abort called for test ${testNumber}`); | ||||||
clearInterval(interval); | ||||||
return; | ||||||
} | ||||||
|
||||||
if(retries > 100) { | ||||||
clearInterval(interval); | ||||||
throw new Error(`abort was not called for test ${testNumber}`); | ||||||
} | ||||||
}, 10); | ||||||
} | ||||||
} |
Uh oh!
There was an error while loading. Please reload this page.