From 19b52625242b7bb551746083a625f93868caf9da Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 22 Mar 2024 16:37:11 -0400 Subject: [PATCH 1/3] 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: https://github.com/nodejs/node/issues/49120 --- test/common/test-error-reporter.js | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/common/test-error-reporter.js diff --git a/test/common/test-error-reporter.js b/test/common/test-error-reporter.js new file mode 100644 index 00000000000000..3098b10885f19d --- /dev/null +++ b/test/common/test-error-reporter.js @@ -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'); + } + } +}; From 5c7e4bf6a820d4e519f4768551a18d5b4c54a8ca Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 22 Mar 2024 17:17:04 -0400 Subject: [PATCH 2/3] temp - add a failure --- test/parallel/test-runner-cli-concurrency.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/parallel/test-runner-cli-concurrency.js b/test/parallel/test-runner-cli-concurrency.js index b2aa0ac6c3c6c5..1373b4ff92606b 100644 --- a/test/parallel/test-runner-cli-concurrency.js +++ b/test/parallel/test-runner-cli-concurrency.js @@ -23,6 +23,7 @@ test('concurrency of two', async () => { 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'); }); test('isolation=none uses a concurrency of one', async () => { From 5dc2c0a6335fcd10c261b128a536c55c60dd06a3 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 18 Dec 2024 15:22:45 -0500 Subject: [PATCH 3/3] apply to GHA --- .github/workflows/build-tarball.yml | 2 +- .github/workflows/coverage-linux-without-intl.yml | 2 +- .github/workflows/coverage-linux.yml | 2 +- .github/workflows/doc.yml | 2 +- .github/workflows/test-asan.yml | 2 +- .github/workflows/test-linux.yml | 2 +- .github/workflows/test-macos.yml | 2 +- .github/workflows/test-ubsan.yml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-tarball.yml b/.github/workflows/build-tarball.yml index 7d8b38a21f8831..2ed30ba0c6c568 100644 --- a/.github/workflows/build-tarball.yml +++ b/.github/workflows/build-tarball.yml @@ -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" diff --git a/.github/workflows/coverage-linux-without-intl.yml b/.github/workflows/coverage-linux-without-intl.yml index 1977eda3f97e03..e88310dc414cab 100644 --- a/.github/workflows/coverage-linux-without-intl.yml +++ b/.github/workflows/coverage-linux-without-intl.yml @@ -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: diff --git a/.github/workflows/coverage-linux.yml b/.github/workflows/coverage-linux.yml index 164c0b540a9f45..770205a317088c 100644 --- a/.github/workflows/coverage-linux.yml +++ b/.github/workflows/coverage-linux.yml @@ -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: diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 5ab4277879ecb9..c86d0c5822f82f 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -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" diff --git a/.github/workflows/test-asan.yml b/.github/workflows/test-asan.yml index d918fa7d87300b..e579e9e2fd2275 100644 --- a/.github/workflows/test-asan.yml +++ b/.github/workflows/test-asan.yml @@ -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" diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 24cf47f9b376bd..8212fe99736de9 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -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" diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 6bb22265032605..ece07f832e256b 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -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" diff --git a/.github/workflows/test-ubsan.yml b/.github/workflows/test-ubsan.yml index 9f33fa670b8231..3587e9d3125666 100644 --- a/.github/workflows/test-ubsan.yml +++ b/.github/workflows/test-ubsan.yml @@ -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"