Skip to content
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

fix(cli): use Instant for test times #22853

Merged
merged 1 commit into from
Mar 12, 2024
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
7 changes: 3 additions & 4 deletions cli/tools/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ use std::sync::Arc;
use std::task::Poll;
use std::time::Duration;
use std::time::Instant;
use std::time::SystemTime;
use tokio::signal;

mod channel;
Expand Down Expand Up @@ -769,7 +768,7 @@ async fn run_tests_for_worker_inner(
// We always capture stats, regardless of sanitization state
let before = stats.clone().capture(&filter);

let earlier = SystemTime::now();
let earlier = Instant::now();
let call = worker.js_runtime.call(&function);
let result = match worker
.js_runtime
Expand Down Expand Up @@ -807,7 +806,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);
let elapsed = SystemTime::now().duration_since(earlier)?.as_millis();
let elapsed = earlier.elapsed().as_millis();
sender.send(TestEvent::Result(
desc.id,
TestResult::Failed(failure),
Expand All @@ -823,7 +822,7 @@ async fn run_tests_for_worker_inner(
if matches!(result, TestResult::Failed(_)) {
fail_fast_tracker.add_failure();
}
let elapsed = SystemTime::now().duration_since(earlier)?.as_millis();
let elapsed = earlier.elapsed().as_millis();
sender.send(TestEvent::Result(desc.id, result, elapsed as u64))?;
}
Ok(())
Expand Down