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

Pull latest commits from node core #43

Merged
merged 24 commits into from
Feb 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
012acb0
feat: verbous error when entire test tree is canceled
MoLow Aug 2, 2022
d885ee2
feat: support programmatically running `--test`
MoLow Aug 15, 2022
27241c3
fix: fix `duration_ms` to be milliseconds
MoLow Sep 4, 2022
6755536
feat: support using `--inspect` with `--test`
MoLow Sep 10, 2022
c50f844
fix: include stack of uncaught exceptions
MoLow Sep 14, 2022
1950b38
test: fix test-runner-inspect
MoLow Sep 14, 2022
c5fd64c
feat: add --test-name-pattern CLI flag
cjihrig Sep 1, 2022
46dce07
feat: add extra fields in AssertionError YAML
bengl Oct 26, 2022
0bfdb77
fix: call {before,after}Each() on suites
cjihrig Oct 27, 2022
08269c5
fix: report tap subtest in order
MoLow Oct 28, 2022
f2815af
fix: fix afterEach not running on test failures
MrJithil Nov 7, 2022
cff397a
fix: avoid swallowing of asynchronously thrown errors
fossamagna Nov 7, 2022
2e499ee
feat: support function mocking
cjihrig Apr 4, 2022
5f8ce61
feat: add initial TAP parser
manekinekko Nov 21, 2022
5ba2500
fix: remove stdout and stderr from error
cjihrig Nov 25, 2022
b942f93
feat: add getter and setter to MockTracker
fossamagna Nov 18, 2022
b3b384e
fix: don't use a symbol for runHook()
cjihrig Dec 6, 2022
71b659e
feat: add t.after() hook
cjihrig Dec 8, 2022
c0854ac
test: fix invalid output TAP if there newline in test name
pulkit-30 Dec 11, 2022
9b49978
chore: refactor `tap_parser` to use more primordials
aduh95 Dec 11, 2022
4e778bc
chore: refactor `tap_lexer` to use more primordials
aduh95 Dec 12, 2022
d1343a7
feat: parse yaml
MoLow Dec 13, 2022
c80e426
fix: run t.after() if test body throws
cjihrig Dec 17, 2022
9fa496b
test: fix mock.method to support class instances
ErickWendel Dec 17, 2022
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
Prev Previous commit
Next Next commit
fix: run t.after() if test body throws
This commit fixes a bug where t.after() was not called if the
test body threw an exception.

PR-URL: nodejs/node#45870
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
(cherry picked from commit 385d595a4f1d887f6d4221e6071571132498d57c)
  • Loading branch information
cjihrig authored and MoLow committed Feb 2, 2023
commit c80e426984408b2ef131ad05e2beb61715482046
10 changes: 8 additions & 2 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/nodejs/node/blob/232efb06fe8787e9573e298ce7ac293ad23b7684/lib/internal/test_runner/test.js
// https://github.com/nodejs/node/blob/385d595a4f1d887f6d4221e6071571132498d57c/lib/internal/test_runner/test.js

'use strict'

@@ -496,6 +496,11 @@ class Test extends AsyncResource {
}

const { args, ctx } = this.getRunArgs()
const after = runOnce(async () => {
if (this.hooks.after.length > 0) {
await this.runHook('after', { args, ctx })
}
})
const afterEach = runOnce(async () => {
if (this.parent?.hooks.afterEach.length > 0) {
await this.parent.runHook('afterEach', { args, ctx })
@@ -537,10 +542,11 @@ class Test extends AsyncResource {
return
}

await this.runHook('after', { args, ctx })
await after()
await afterEach()
this.pass()
} catch (err) {
try { await after() } catch { /* Ignore error. */ }
try { await afterEach() } catch { /* test is already failing, let's the error */ }
if (isTestFailureError(err)) {
if (err.failureType === kTestTimeoutFailure) {
9 changes: 8 additions & 1 deletion test/message/test_runner_hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/nodejs/node/blob/215c5317d4837287fddb2e3b97872babd53183ac/test/message/test_runner_hooks.js
// https://github.com/nodejs/node/blob/385d595a4f1d887f6d4221e6071571132498d57c/test/message/test_runner_hooks.js
// Flags: --no-warnings
'use strict'
const common = require('../common')
@@ -142,3 +142,10 @@ test('afterEach throws and test fails', async (t) => {
await t.test('1', () => { throw new Error('test') })
await t.test('2', () => {})
})

test('t.after() is called if test body throws', (t) => {
t.after(() => {
t.diagnostic('- after() called')
})
throw new Error('bye')
})
24 changes: 21 additions & 3 deletions test/message/test_runner_hooks.out
Original file line number Diff line number Diff line change
@@ -475,10 +475,28 @@ not ok 12 - afterEach throws and test fails
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
1..12
# tests 12
# Subtest: t.after() is called if test body throws
not ok 13 - t.after() is called if test body throws
---
duration_ms: *
failureType: 'testCodeFailure'
error: 'bye'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
...
# - after() called
1..13
# tests 13
# pass 2
# fail 10
# fail 11
# cancelled 0
# skipped 0
# todo 0