1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Embedded tests for `src/native/test_runner.rs` helpers. Cover
//! the defensive branches (flaky-final-replay panic and TooSlow
//! health-check) that were previously masked by `// nocov` annotations.
use super::*;
use std::time::Duration;
#[test]
fn too_slow_check_panics_when_under_threshold_and_unsuppressed() {
let result = std::panic::catch_unwind(|| {
too_slow_check(
/* valid_test_cases */ 1,
/* total_test_time */ Duration::from_secs(60),
/* threshold */ Duration::from_secs(30),
/* suppressed */ false,
);
});
assert!(result.is_err(), "expected too_slow_check to panic");
}
#[test]
fn too_slow_check_quiet_when_suppressed() {
too_slow_check(
/* valid_test_cases */ 1,
/* total_test_time */ Duration::from_secs(60),
/* threshold */ Duration::from_secs(30),
/* suppressed */ true,
);
}
#[test]
fn too_slow_check_quiet_when_under_threshold() {
too_slow_check(
/* valid_test_cases */ 1,
/* total_test_time */ Duration::from_secs(1),
/* threshold */ Duration::from_secs(30),
/* suppressed */ false,
);
}
#[test]
fn too_slow_check_quiet_when_enough_valid_cases() {
// Once enough valid cases have run, the health check is no longer
// applied even if total_test_time exceeds the threshold.
too_slow_check(
/* valid_test_cases */ 10_000,
/* total_test_time */ Duration::from_secs(60),
/* threshold */ Duration::from_secs(30),
/* suppressed */ false,
);
}
#[test]
#[should_panic(expected = "Flaky test detected")]
fn flaky_final_replay_panic_panics_with_diagnostic() {
flaky_final_replay_panic();
}