GeezerVison is showing github.com — test: add error only reporter for node:test · nodejs/node@323f96f
File treeExpand file treeCollapse file tree Open diff view settings fixtures/test-runner/error-reporter-fail-fast
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/build-tarball.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,4 +105,4 @@ jobs: | 105 | 105 | - name: Test | 106 | 106 | run: | | 107 | 107 | 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 Copy file name to clipboardExpand all lines: .github/workflows/coverage-linux-without-intl.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 68 | 68 | # TODO(bcoe): fix the couple tests that fail with the inspector enabled. | 69 | 69 | # The cause is most likely coverage's use of the inspector. | 70 | 70 | - 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 | 72 | 72 | - name: Report JS | 73 | 73 | run: npx c8 report --check-coverage | 74 | 74 | env: | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/coverage-linux.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 68 | 68 | # TODO(bcoe): fix the couple tests that fail with the inspector enabled. | 69 | 69 | # The cause is most likely coverage's use of the inspector. | 70 | 70 | - 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 | 72 | 72 | - name: Report JS | 73 | 73 | run: npx c8 report --check-coverage | 74 | 74 | env: | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/doc.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 40 | 40 | name: docs | 41 | 41 | path: out/doc | 42 | 42 | - 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 Copy file name to clipboardExpand all lines: .github/workflows/test-asan.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 63 | 63 | - name: Build | 64 | 64 | run: make build-ci -j4 V=1 | 65 | 65 | - 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 Copy file name to clipboardExpand all lines: .github/workflows/test-linux.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 54 | 54 | - name: Build | 55 | 55 | run: make -C node build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn" | 56 | 56 | - 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" | 58 | 58 | - name: Re-run test in a folder whose name contains unusual chars | 59 | 59 | run: | | 60 | 60 | mv node "$DIR" | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test-macos.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 89 | 89 | - name: Free Space After Build | 90 | 90 | run: df -h | 91 | 91 | - 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" | 93 | 93 | - name: Re-run test in a folder whose name contains unusual chars | 94 | 94 | run: | | 95 | 95 | mv node "$DIR" | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/test-ubsan.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 64 | 64 | - name: Build | 65 | 65 | run: make build-ci -j2 V=1 | 66 | 66 | - 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 Copy file name to clipboard +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 Copy file name to clipboard +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +const assert = require('node:assert'); | | 2 | +const { test } = require('node:test'); | | 3 | + | | 4 | +test('fail', () => { | | 5 | + assert.fail('a.mjs fail'); | | 6 | +}); |
|