forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit updates the test runner to allow a forced exit once all known tests have finished running. Fixes: nodejs#49925
- Loading branch information
Showing
15 changed files
with
170 additions
and
10 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Flags: --test-force-exit --test-reporter=spec | ||
'use strict'; | ||
const { after, afterEach, before, beforeEach, test } = require('node:test'); | ||
|
||
before(() => { | ||
console.log('BEFORE'); | ||
}); | ||
|
||
beforeEach(() => { | ||
console.log('BEFORE EACH'); | ||
}); | ||
|
||
after(() => { | ||
console.log('AFTER'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.log('AFTER EACH'); | ||
}); | ||
|
||
test('passes but oops', () => { | ||
setTimeout(() => { | ||
throw new Error('this should not have a chance to be thrown'); | ||
}, 1000); | ||
}); | ||
|
||
test('also passes'); |
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,16 @@ | ||
BEFORE | ||
BEFORE EACH | ||
AFTER EACH | ||
BEFORE EACH | ||
AFTER EACH | ||
AFTER | ||
✔ passes but oops (*ms) | ||
✔ also passes (*ms) | ||
ℹ tests 2 | ||
ℹ suites 0 | ||
ℹ pass 2 | ||
ℹ 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
const { test } = require('node:test'); | ||
|
||
test('fails and schedules more work', () => { | ||
setTimeout(() => { | ||
throw new Error('this should not have a chance to be thrown'); | ||
}, 1000); | ||
|
||
throw new Error('fails'); | ||
}); |
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,15 @@ | ||
'use strict'; | ||
require('../common'); | ||
const { match, doesNotMatch, strictEqual } = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
const fixtures = require('../common/fixtures'); | ||
const fixture = fixtures.path('test-runner/throws_sync_and_async.js'); | ||
const r = spawnSync(process.execPath, ['--test', '--test-force-exit', fixture]); | ||
|
||
strictEqual(r.status, 1); | ||
strictEqual(r.signal, null); | ||
strictEqual(r.stderr.toString(), ''); | ||
|
||
const stdout = r.stdout.toString(); | ||
match(stdout, /error: 'fails'/); | ||
doesNotMatch(stdout, /this should not have a chance to be thrown/); |
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