-
Notifications
You must be signed in to change notification settings - Fork 5k
node:test: report t.test() after parent finished as a parentAlreadyFinished failure #34583
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
Open
robobun
wants to merge
10
commits into
main
Choose a base branch
from
claude/farm-7db298bf-node-test-late-subtest-failure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9123069
node:test: report t.test() after parent finished as a parentAlreadyFi…
robobun 8832af3
address review: worker IPC routing, no-op done for 2-arg late bodies,…
robobun eb56350
test: assert late-done is reported and late-skip/late-todo are not
robobun 034a983
address review: mirror --bail check after late-subtest fail increment
robobun 05b016a
address review: skip body of late {skip:true} subtest and reset its m…
robobun 2e26cac
test: rename output marker to avoid diff-hygiene grep false positive
robobun 03fa9a9
ci: retrigger
robobun 975fc45
address review: defer child.finished until after body so nested t.tes…
robobun 274b5fe
clippy: use writeln! instead of write! with trailing newline
robobun b723491
address review: use write_test_status_line instead of duplicating the…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/js/node/test_runner/fixtures/25-late-subtest-failure.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| const { test } = require("node:test"); | ||
| const assert = require("node:assert"); | ||
|
|
||
| // A t.test() that escapes its parent (the forgot-to-await shape): Node runs the | ||
| // body, resolves the returned promise with undefined, and records the late | ||
| // subtest as a parentAlreadyFinished failure so the run exits 1. Before the | ||
| // fix, bun resolved the promise but dropped the failure and exited 0. | ||
| let saved; | ||
| let bodyRan = false; | ||
| let doneBodyRan = false; | ||
| let suiteBodyRan = false; | ||
| let resolvedWith = "unset"; | ||
|
|
||
| test("parent", t => { | ||
| saved = t; | ||
| }); | ||
|
|
||
| test("observer", async () => { | ||
| const result = await saved.test("late", () => { | ||
| bodyRan = true; | ||
| }); | ||
| resolvedWith = result; | ||
| console.log("RESOLVED_WITH=" + String(resolvedWith)); | ||
| console.log("BODY_RAN=" + String(bodyRan)); | ||
| // A (t, done) body must receive a callable done so the body runs to completion. | ||
| await saved.test("late-done", (_t, done) => { | ||
| done(); | ||
| doneBodyRan = true; | ||
| }); | ||
| console.log("DONE_BODY_RAN=" + String(doneBodyRan)); | ||
| // t.describe() after the parent finished takes the same path (isSuite=true). | ||
| await saved.describe("late-suite", () => { | ||
| suiteBodyRan = true; | ||
| }); | ||
| console.log("SUITE_BODY_RAN=" + String(suiteBodyRan)); | ||
| // A late skip/todo subtest is not counted as a failure (Node exits 0 for | ||
| // those); these must not add further fail entries to this run. Node replaces | ||
| // a {skip:true} body with a noop, so it must not run; a {todo:true} body does. | ||
| let skipBodyRan = false; | ||
| let todoBodyRan = false; | ||
| await saved.test("late-skip", { skip: true }, () => { | ||
| skipBodyRan = true; | ||
| }); | ||
| await saved.test("late-todo", { todo: true }, () => { | ||
| todoBodyRan = true; | ||
| }); | ||
| console.log("SKIP_BODY_RAN=" + String(skipBodyRan)); | ||
| console.log("MARKED_BODY_RAN=" + String(todoBodyRan)); | ||
| }); | ||
|
robobun marked this conversation as resolved.
|
||
|
|
||
| process.on("exit", () => { | ||
| assert.strictEqual(bodyRan, true, "late subtest body must run (Node runs it)"); | ||
| assert.strictEqual(resolvedWith, undefined, "late subtest promise must resolve to undefined"); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.