Repository navigation
fix(test): prevent an untracked child in the mutation baseline #4416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -395,21 +395,20 @@ | |
| if (claim.status !== 'acquired') throw new Error('fixture claim refused'); | ||
| let released = false; | ||
| spawn.mockImplementation((_command, _args, options) => { | ||
| if (spawn.mock.calls.length !== 1) | ||
| throw new Error('no second launch: the retry boundary must be observable without a sweeper'); | ||
| const child = spawnRegisteredDaemonFixture(paths, fields(http.port), options, undefined, { | ||
| emitStartupMarkerBeforeAcquisition: true, | ||
| }); | ||
| if (spawn.mock.calls.length === 1) { | ||
| void child.exited.then((exit) => { | ||
| assert.equal(exit.exitCode, DAEMON_STARTUP_EXIT_CODES.busy); | ||
| if (!released) { | ||
| void claim.acquisition.release().then(() => { | ||
| released = true; | ||
| }); | ||
| } | ||
| }); | ||
| return child; | ||
| } | ||
| throw new Error('no second launch: the retry boundary must be observable without a sweeper'); | ||
| void child.exited.then((exit) => { | ||
| assert.equal(exit.exitCode, DAEMON_STARTUP_EXIT_CODES.busy); | ||
| if (!released) { | ||
| void claim.acquisition.release().then(() => { | ||
| released = true; | ||
| }); | ||
| } | ||
| }); | ||
| return child; | ||
| }); | ||
| pause.mockImplementation((ms) => actualRetry.sleep(Math.min(Number(ms), 50))); | ||
| try { | ||
|
|
@@ -418,6 +417,11 @@ | |
| (error: unknown) => | ||
| error instanceof AppError && error.details?.kind === 'daemon_startup_failed', | ||
| ); | ||
| assert.equal( | ||
| fs.readdirSync(path.join(paths.baseDir, 'fixture-entries')).length, | ||
| 1, | ||
| 'the refused retry must not launch another marker writer', | ||
| ); | ||
|
Check warning on line 424 in packages/daemon-client/src/__tests__/daemon-client-startup-race.test.ts
|
||
|
Comment on lines
+420
to
+424
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Minor · New assertion checks the mock's own throw, so it cannot fail on any production change The Suggested change assert.equal(spawn.mock.calls.length, 1, 'the refused retry must not launch another marker writer'); DetailsAlso raised hereAlso raised at this location by persona Also raised at this location by persona persona: Useful? Reply Reply |
||
| assert.deepEqual( | ||
| fs.readdirSync(paths.baseDir).filter((e) => e.startsWith('daemon-startup-phases')), | ||
| [], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The new
fixture-entriescount only proves no fixture child was written; it does not prove the retry was never attempted, because the refused spawn throws and is swallowed as a startup error. Assert the spawn count directly after the rejection so a retry attempt fails the test.Prompt for AI agents