-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: run global after() hook earlier
This commit moves the global after() hook execution from the 'beforeExit' event to the point where all tests have finished running. This gives the global after() a chance to clean up handles that would otherwise prevent the 'beforeExit' event from being emitted. PR-URL: #49059 Fixes: #49056 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
Showing
7 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/fixtures/test-runner/output/async-test-scheduling.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as common from '../../../common/index.mjs'; | ||
import { describe, test } from 'node:test'; | ||
import { setTimeout } from 'node:timers/promises'; | ||
|
||
test('test', common.mustCall()); | ||
describe('suite', common.mustCall(async () => { | ||
test('test', common.mustCall()); | ||
await setTimeout(10); | ||
test('scheduled async', common.mustCall()); | ||
})); | ||
|
||
await setTimeout(10); | ||
test('scheduled async', common.mustCall()); |
37 changes: 37 additions & 0 deletions
37
test/fixtures/test-runner/output/async-test-scheduling.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
TAP version 13 | ||
# Subtest: test | ||
ok 1 - test | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: suite | ||
# Subtest: test | ||
ok 1 - test | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: scheduled async | ||
ok 2 - scheduled async | ||
--- | ||
duration_ms: * | ||
... | ||
1..2 | ||
ok 2 - suite | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: scheduled async | ||
ok 3 - scheduled async | ||
--- | ||
duration_ms: * | ||
... | ||
1..3 | ||
# tests 4 | ||
# suites 1 | ||
# pass 4 | ||
# fail 0 | ||
# cancelled 0 | ||
# skipped 0 | ||
# todo 0 | ||
# duration_ms * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/parallel/test-runner-root-after-with-refed-handles.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const { before, after, test } = require('node:test'); | ||
const { createServer } = require('node:http'); | ||
|
||
let server; | ||
|
||
before(common.mustCall(() => { | ||
server = createServer(); | ||
|
||
return new Promise(common.mustCall((resolve, reject) => { | ||
server.listen(0, common.mustCall((err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
})); | ||
})); | ||
})); | ||
|
||
after(common.mustCall(() => { | ||
server.close(); | ||
})); | ||
|
||
test(); |