Skip to content
Merged
Changes from all commits
Commits
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
32 changes: 20 additions & 12 deletions apps/cli/tests/daemon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,26 @@ describe( 'ProcessManagerDaemon', () => {
2,
'0'
) }${ String( now.getDate() ).padStart( 2, '0' ) }`;
expect(
fs.readFileSync(
path.join( tmpDir, 'logs', `${ testProcessName }-out-${ dateTag }.log` ),
'utf8'
)
).toContain( 'fixture-stdout' );
expect(
fs.readFileSync(
path.join( tmpDir, 'logs', `${ testProcessName }-error-${ dateTag }.log` ),
'utf8'
)
).toContain( 'fixture-stderr' );
// The daemon pipes child output through readline into a buffered WriteStream, so the
// bytes reach disk several async hops after we write them. Poll until the output
// lands; the flush can lag on slower agents (notably Windows CI).
await vi.waitFor(
() => {
expect(
fs.readFileSync(
path.join( tmpDir, 'logs', `${ testProcessName }-out-${ dateTag }.log` ),
'utf8'
)
).toContain( 'fixture-stdout' );
expect(
fs.readFileSync(
path.join( tmpDir, 'logs', `${ testProcessName }-error-${ dateTag }.log` ),
'utf8'
)
).toContain( 'fixture-stderr' );
},
{ timeout: 2000 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we use a default polling interval of 50ms. Would it make sense to use a longer one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value is the total time the test will wait for the expectation to pass before failing, the polling interval for the waitFor has a default of 50 ms docs here so that's coherent with existing functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the question was whether we need to poll every 50ms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahms, sorry I misunderstood. I actually don't know, but I think this should be completed in ms so 50 seems reasonable, do you think we should it increase it to maybe 100ms? I don't mind either case.

);
} );

it( 'includes captured stderr in the exit event payload', async () => {
Expand Down