Skip to content
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

test: add error only reporter for node:test #52189

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ jobs:
- name: Test
run: |
cd $TAR_DIR
make run-ci -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=spec' --measure-flakiness 9"
make run-ci -j4 V=1 TEST_CI_ARGS="-p dots --node-args='--test-reporter=./test/common/test-error-reporter.js' --measure-flakiness 9"
2 changes: 1 addition & 1 deletion .github/workflows/coverage-linux-without-intl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
# The cause is most likely coverage's use of the inspector.
- name: Test
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
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
- name: Report JS
run: npx c8 report --check-coverage
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
# TODO(bcoe): fix the couple tests that fail with the inspector enabled.
# The cause is most likely coverage's use of the inspector.
- name: Test
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
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
- name: Report JS
run: npx c8 report --check-coverage
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
name: docs
path: out/doc
- name: Test
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"
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"
2 changes: 1 addition & 1 deletion .github/workflows/test-asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
- name: Build
run: make build-ci -j4 V=1
- name: Test
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"
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"
2 changes: 1 addition & 1 deletion .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
- name: Build
run: make build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn"
- name: Test
run: make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --node-args='--test-reporter=spec' --node-args='--test-reporter-destination=stdout' --measure-flakiness 9"
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' --measure-flakiness 9"
2 changes: 1 addition & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ jobs:
- name: Free Space After Build
run: df -h
- name: Test
run: make 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"
run: make 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"
2 changes: 1 addition & 1 deletion .github/workflows/test-ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ jobs:
- name: Build
run: make build-ci -j2 V=1
- name: Test
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"
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"
35 changes: 35 additions & 0 deletions test/common/test-error-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';
const { relative } = require('node:path');
const { inspect } = require('node:util');
const cwd = process.cwd();

module.exports = async function* errorReporter(source) {
for await (const event of source) {
if (event.type === 'test:fail') {
const { name, details, line, column, file } = event.data;
let { error } = details;

if (error?.failureType === 'subtestsFailed') {
// In the interest of keeping things concise, skip failures that are
// only due to nested failures.
continue;
}

if (error?.code === 'ERR_TEST_FAILURE') {
error = error.cause;
}

const output = [
`Test failure: '${name}'`,
];

if (file) {
output.push(`Location: ${relative(cwd, file)}:${line}:${column}`);
}

output.push(inspect(error));
output.push('\n');
yield output.join('\n');
Comment on lines +22 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not yield the values directly, instead of having the output value?

}
}
};
1 change: 1 addition & 0 deletions test/parallel/test-runner-cli-concurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
const args = ['--test', '--test-concurrency=2'];
const cp = spawnSync(process.execPath, args, { cwd, env });
assert.match(cp.stderr.toString(), /concurrency: 2,/);
throw new Error('bye');

Check failure on line 26 in test/parallel/test-runner-cli-concurrency.js

View workflow job for this annotation

GitHub Actions / test-linux

--- stdout --- ::debug::starting to run default concurrency ::debug::completed running default concurrency ::debug::starting to run concurrency of one ::debug::completed running concurrency of one ::debug::starting to run concurrency of two ::error title=concurrency of two,file=test/parallel/test-runner-cli-concurrency.js,line=26,col=9::[Error [ERR_TEST_FAILURE]: bye] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Error: bye at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js:26:9) at Test.runInAsyncScope (node:async_hooks:211:14) at Test.run (node:internal/test_runner/test:931:25) at Test.processPendingSubtests (node:internal/test_runner/test:629:18) at Test.postRun (node:internal/test_runner/test:1042:19) at Test.run (node:internal/test_runner/test:970:12) at async Test.processPendingSubtests (node:internal/test_runner/test:629:7) } Test failure: 'concurrency of two' Location: test/parallel/test-runner-cli-concurrency.js:22:1 Error: bye at TestContext.<anonymous> (/home/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js:26:9) at Test.runInAsyncScope (node:async_hooks:211:14) at Test.run (node:internal/test_runner/test:931:25) at Test.processPendingSubtests (node:internal/test_runner/test:629:18) at Test.postRun (node:internal/test_runner/test:1042:19) at Test.run (node:internal/test_runner/test:970:12) at async Test.processPendingSubtests (node:internal/test_runner/test:629:7) ::debug::starting to run isolation=none uses a concurrency of one ::debug::completed running isolation=none uses a concurrency of one ::debug::starting to run isolation=none overrides --test-concurrency ::debug::completed running isolation=none overrides --test-concurrency ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::tests 5 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::suites 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::pass 4 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::fail 1 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::cancelled 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::skipped 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::todo 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::duration_ms 1251.612068 ::group::Test results (4 passed, 1 failed) ::notice:: ::endgroup:: Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js

Check failure on line 26 in test/parallel/test-runner-cli-concurrency.js

View workflow job for this annotation

GitHub Actions / test-macOS

--- stdout --- ::debug::starting to run default concurrency ::debug::completed running default concurrency ::debug::starting to run concurrency of one ::debug::completed running concurrency of one ::debug::starting to run concurrency of two ::error title=concurrency of two,file=test/parallel/test-runner-cli-concurrency.js,line=26,col=9::[Error [ERR_TEST_FAILURE]: bye] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Error: bye at TestContext.<anonymous> (/Users/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js:26:9) at Test.runInAsyncScope (node:async_hooks:211:14) at Test.run (node:internal/test_runner/test:931:25) at Test.processPendingSubtests (node:internal/test_runner/test:629:18) at Test.postRun (node:internal/test_runner/test:1042:19) at Test.run (node:internal/test_runner/test:970:12) at async Test.processPendingSubtests (node:internal/test_runner/test:629:7) } Test failure: 'concurrency of two' Location: test/parallel/test-runner-cli-concurrency.js:22:1 Error: bye at TestContext.<anonymous> (/Users/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js:26:9) at Test.runInAsyncScope (node:async_hooks:211:14) at Test.run (node:internal/test_runner/test:931:25) at Test.processPendingSubtests (node:internal/test_runner/test:629:18) at Test.postRun (node:internal/test_runner/test:1042:19) at Test.run (node:internal/test_runner/test:970:12) at async Test.processPendingSubtests (node:internal/test_runner/test:629:7) ::debug::starting to run isolation=none uses a concurrency of one ::debug::completed running isolation=none uses a concurrency of one ::debug::starting to run isolation=none overrides --test-concurrency ::debug::completed running isolation=none overrides --test-concurrency ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::tests 5 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::suites 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::pass 4 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::fail 1 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::cancelled 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::skipped 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::todo 0 ::notice file=test/parallel/test-runner-cli-concurrency.js,line=1,col=1::duration_ms 1457.217333 ::group::Test results (4 passed, 1 failed) ::notice:: ::endgroup:: Command: out/Release/node --test-reporter=./test/common/test-error-reporter.js --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /Users/runner/work/node/node/test/parallel/test-runner-cli-concurrency.js
});

test('isolation=none uses a concurrency of one', async () => {
Expand Down
Loading