Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 323f96f

Browse filesBrowse files
Ceres6aduh95
authored andcommitted
test: add error only reporter for node:test
This commit introduces a node:test reporter to the common utils. This reporter can be used to silence output other than errors from node:test. This is useful because in Node's own test suite, the output of node:test is included in the output of the Python test runner. Refs: #49120 PR-URL: #56438 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 4e4b0c6 commit 323f96f
Copy full SHA for 323f96f

File tree

Expand file treeCollapse file tree

12 files changed

+93
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

12 files changed

+93
-8
lines changed
Open diff view settings
Collapse file

‎.github/workflows/build-tarball.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/build-tarball.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ jobs:
105105
- name: Test
106106
run: |
107107
cd $TAR_DIR
108-
make run-ci -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=spec' --measure-flakiness 9"
108+
make run-ci -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=./test/common/test-error-reporter.js' --measure-flakiness 9"
Collapse file

‎.github/workflows/coverage-linux-without-intl.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/coverage-linux-without-intl.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
6969
# The cause is most likely coverage's use of the inspector.
7070
- name: Test
71-
run: NODE_V8_COVERAGE=coverage/tmp make test-cov -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=spec' --measure-flakiness 9" || exit 0
71+
run: NODE_V8_COVERAGE=coverage/tmp make test-cov -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=./test/common/test-error-reporter.js' --measure-flakiness 9" || exit 0
7272
- name: Report JS
7373
run: npx c8 report --check-coverage
7474
env:
Collapse file

‎.github/workflows/coverage-linux.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/coverage-linux.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
6969
# The cause is most likely coverage's use of the inspector.
7070
- name: Test
71-
run: NODE_V8_COVERAGE=coverage/tmp make test-cov -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=spec' --measure-flakiness 9" || exit 0
71+
run: NODE_V8_COVERAGE=coverage/tmp make test-cov -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=./test/common/test-error-reporter.js' --measure-flakiness 9" || exit 0
7272
- name: Report JS
7373
run: npx c8 report --check-coverage
7474
env:
Collapse file

‎.github/workflows/doc.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/doc.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
name: docs
4141
path: out/doc
4242
- name: Test
43-
run: NODE=$(command -v node) make test-doc-ci TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
43+
run: NODE=$(command -v node) make test-doc-ci TEST_CI_ARGS="-p actions --node-args='--test-reporter=./test/common/test-error-reporter.js' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
Collapse file

‎.github/workflows/test-asan.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test-asan.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ jobs:
6363
- name: Build
6464
run: make build-ci -j4 V=1
6565
- name: Test
66-
run: make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' -t 300 --measure-flakiness 9"
66+
run: make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=./test/common/test-error-reporter.js' --node-args='--test-reporter-destination=stdout' -t 300 --measure-flakiness 9"
Collapse file

‎.github/workflows/test-linux.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test-linux.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Build
5555
run: make -C node build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn"
5656
- name: Test
57-
run: make -C node run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
57+
run: make -C node run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=./test/common/test-error-reporter.js' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
5858
- name: Re-run test in a folder whose name contains unusual chars
5959
run: |
6060
mv node "$DIR"
Collapse file

‎.github/workflows/test-macos.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test-macos.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
- name: Free Space After Build
9090
run: df -h
9191
- name: Test
92-
run: make -C node run-ci -j$(getconf _NPROCESSORS_ONLN) V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
92+
run: make -C node run-ci -j$(getconf _NPROCESSORS_ONLN) V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=./test/common/test-error-reporter.js' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
9393
- name: Re-run test in a folder whose name contains unusual chars
9494
run: |
9595
mv node "$DIR"
Collapse file

‎.github/workflows/test-ubsan.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test-ubsan.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ jobs:
6464
- name: Build
6565
run: make build-ci -j2 V=1
6666
- name: Test
67-
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' -t 300 --measure-flakiness 9"
67+
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=./test/common/test-error-reporter.js' --node-args='--test-reporter-destination=stdout' -t 300 --measure-flakiness 9"
Collapse file

‎test/common/test-error-reporter.js‎

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
const { relative } = require('node:path');
3+
const { inspect } = require('node:util');
4+
const cwd = process.cwd();
5+
6+
module.exports = async function* errorReporter(source) {
7+
for await (const event of source) {
8+
if (event.type === 'test:fail') {
9+
const { name, details, line, column, file } = event.data;
10+
let { error } = details;
11+
12+
if (error?.failureType === 'subtestsFailed') {
13+
// In the interest of keeping things concise, skip failures that are
14+
// only due to nested failures.
15+
continue;
16+
}
17+
18+
if (error?.code === 'ERR_TEST_FAILURE') {
19+
error = error.cause;
20+
}
21+
22+
const output = [
23+
`Test failure: '${name}'`,
24+
];
25+
26+
if (file) {
27+
output.push(`Location: ${relative(cwd, file)}:${line}:${column}`);
28+
}
29+
30+
output.push(inspect(error));
31+
output.push('\n');
32+
yield output.join('\n');
33+
34+
if (process.env.FAIL_FAST) {
35+
yield `\nBailing on failed test: ${event.data.name}\n`;
36+
process.exitCode = 1;
37+
process.emit('SIGINT');
38+
}
39+
}
40+
}
41+
};
Collapse file
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const assert = require('node:assert');
2+
const { test } = require('node:test');
3+
4+
test('fail', () => {
5+
assert.fail('a.mjs fail');
6+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.