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

fix(cli): show asserts before leaks (#22904)

Fixes #22837
This commit is contained in:
Matt Mastracci 2024-03-13 20:49:54 -06:00 committed by GitHub
parent bc782cee98
commit 1f3c4c9763
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 6 deletions

View file

@ -792,6 +792,19 @@ async fn run_tests_for_worker_inner(
}
};
// Check the result before we check for leaks
let result = {
let scope = &mut worker.js_runtime.handle_scope();
let result = v8::Local::new(scope, result);
serde_v8::from_v8::<TestResult>(scope, result)?
};
if matches!(result, TestResult::Failed(_)) {
fail_fast_tracker.add_failure();
let elapsed = earlier.elapsed().as_millis();
sender.send(TestEvent::Result(desc.id, result, elapsed as u64))?;
continue;
}
// Await activity stabilization
if let Some(diff) = wait_for_activity_to_stabilize(
worker,
@ -806,6 +819,7 @@ async fn run_tests_for_worker_inner(
let (formatted, trailer_notes) = format_sanitizer_diff(diff);
if !formatted.is_empty() {
let failure = TestFailure::Leaked(formatted, trailer_notes);
fail_fast_tracker.add_failure();
let elapsed = earlier.elapsed().as_millis();
sender.send(TestEvent::Result(
desc.id,
@ -816,12 +830,6 @@ async fn run_tests_for_worker_inner(
}
}
let scope = &mut worker.js_runtime.handle_scope();
let result = v8::Local::new(scope, result);
let result = serde_v8::from_v8::<TestResult>(scope, result)?;
if matches!(result, TestResult::Failed(_)) {
fail_fast_tracker.add_failure();
}
let elapsed = earlier.elapsed().as_millis();
sender.send(TestEvent::Result(desc.id, result, elapsed as u64))?;
}

View file

@ -0,0 +1,5 @@
{
"args": "test --quiet --reload main.js",
"output": "main.out",
"exitCode": 1
}

View file

@ -0,0 +1,6 @@
Deno.test(function throws() {
// Leak
setTimeout(() => {}, 60_000);
// But the exception should mask the leak
throw new Error("Throws");
});

View file

@ -0,0 +1,18 @@
running 1 test from ./main.js
throws ... FAILED ([WILDCARD])
ERRORS
throws => ./main.js:1:6
error: Error: Throws
throw new Error("Throws");
^
at throws ([WILDCARD]/main.js:5:9)
FAILURES
throws => ./main.js:1:6
FAILED | 0 passed | 1 failed ([WILDCARD])
error: Test failed