1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 00:59:24 -05:00

fix(cli): force flush output after test unloads (#22660)

Fixes flake in load_unload test
This commit is contained in:
Matt Mastracci 2024-03-01 14:26:57 -07:00 committed by GitHub
parent 22a4205a68
commit 2e4a1fc3e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -391,7 +391,7 @@ pub enum TestEvent {
StepRegister(TestStepDescription),
StepWait(usize),
StepResult(usize, TestStepResult, u64),
/// Indicates that this worker has completed.
/// Indicates that this worker has completed running tests.
Completed,
/// Indicates that the user has cancelled the test run with Ctrl+C and
/// the run should be aborted.
@ -513,7 +513,7 @@ pub async fn test_specifier(
worker_factory,
permissions,
specifier.clone(),
&worker_sender.sender,
&mut worker_sender.sender,
StdioPipe::file(worker_sender.stdout),
StdioPipe::file(worker_sender.stderr),
fail_fast_tracker,
@ -543,7 +543,7 @@ async fn test_specifier_inner(
worker_factory: Arc<CliMainWorkerFactory>,
permissions: Permissions,
specifier: ModuleSpecifier,
sender: &TestEventSender,
sender: &mut TestEventSender,
stdout: StdioPipe,
stderr: StdioPipe,
fail_fast_tracker: FailFastTracker,
@ -592,6 +592,9 @@ async fn test_specifier_inner(
worker.dispatch_beforeunload_event(located_script_name!())?;
worker.dispatch_unload_event(located_script_name!())?;
// Ensure all output has been flushed
_ = sender.flush();
// Ensure the worker has settled so we can catch any remaining unhandled rejections. We don't
// want to wait forever here.
worker.run_up_to_duration(Duration::from_millis(0)).await?;