-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: handle undefined test locations
This commit updates the built in reporters to check for the documented case of a test's location being undefined. As a drive by fix, the C++ code for computing the test location now returns undefined if the script location is empty. This lets tests run inside of eval(). PR-URL: #52036 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
- Loading branch information
Showing
10 changed files
with
112 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Flags: --test-reporter=dot | ||
'use strict'; | ||
eval(` | ||
const { test } = require('node:test'); | ||
test('passes'); | ||
test('fails', () => { | ||
throw new Error('fail'); | ||
}); | ||
`); |
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 @@ | ||
.X |
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 @@ | ||
// Flags: --test-reporter=spec | ||
'use strict'; | ||
eval(` | ||
const { test } = require('node:test'); | ||
test('passes'); | ||
test('fails', () => { | ||
throw new Error('fail'); | ||
}); | ||
`); |
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,31 @@ | ||
✔ passes (*ms) | ||
✖ fails (*ms) | ||
Error: fail | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
|
||
ℹ tests 2 | ||
ℹ suites 0 | ||
ℹ pass 1 | ||
ℹ fail 1 | ||
ℹ cancelled 0 | ||
ℹ skipped 0 | ||
ℹ todo 0 | ||
ℹ duration_ms * | ||
|
||
✖ failing tests: | ||
|
||
✖ fails (*ms) | ||
Error: fail | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* |
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 @@ | ||
// Flags: --test-reporter=tap | ||
'use strict'; | ||
eval(` | ||
const { test } = require('node:test'); | ||
test('passes'); | ||
test('fails', () => { | ||
throw new Error('fail'); | ||
}); | ||
`); |
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,31 @@ | ||
TAP version 13 | ||
# Subtest: passes | ||
ok 1 - passes | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: fails | ||
not ok 2 - fails | ||
--- | ||
duration_ms: * | ||
failureType: 'testCodeFailure' | ||
error: 'fail' | ||
code: 'ERR_TEST_FAILURE' | ||
stack: |- | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
... | ||
1..2 | ||
# tests 2 | ||
# suites 0 | ||
# pass 1 | ||
# fail 1 | ||
# 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