Skip to content

Commit

Permalink
test-renderers: Add timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Jan 24, 2024
1 parent 9a1eb61 commit 0fe741d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test-renderers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ tempfile = { workspace = true }
# so let's use it for our output report template.
tinytemplate = "1.2.1"
# Using tokio for async test-running.
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "parking_lot", "sync"] }
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "parking_lot", "sync", "time"] }
wgpu = { workspace = true }

[lints]
Expand Down
10 changes: 9 additions & 1 deletion test-renderers/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,16 @@ where
image_serial: 0,
};

// Run the test case; its pass or fail (if it doesn't panic) is determined
// by the comparison_log contents.
// The timeout is in case the renderer hangs, so that we get a faster and more
// specific answer than an entire CI job timeout. (Generally, renders should
// finish in fractions of a second, but CI can be very slow; the large timeout
// is to avoid flakiness under edge cases of high machine load.)
let case_start_time = Instant::now();
(test_case.function)(context).await;
tokio::time::timeout(Duration::from_secs(30), (test_case.function)(context))
.await
.expect("render test case timed out");
case_start_time.elapsed()
});
let outcome: Result<Duration, tokio::task::JoinError> = test_case_handle.await;
Expand Down

0 comments on commit 0fe741d

Please sign in to comment.