Skip to content

Commit

Permalink
test: check tests are run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
brownben committed Nov 8, 2024
1 parent f75255c commit 3e7514b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ fn simple_method() {

#[test]
fn test_times() {
let start_time = std::time::Instant::now();
let results = run_tests!("./examples/test_times.py");
let execution_time = start_time.elapsed();

assert_eq!(results.len(), 5);
assert!(results.iter().all(|x| x.outcome == Outcome::Pass));

// Check that the tests are run in parallel
let total_time = results.iter().flat_map(|result| result.time).sum();
assert!(execution_time < total_time);
}

#[test]
Expand All @@ -55,10 +61,16 @@ fn nested_package_import() {
#[ignore = "takes too long"]
#[test]
fn long_running() {
let start_time = std::time::Instant::now();
let results = run_tests!("./examples/long_running.py");
let execution_time = start_time.elapsed();

assert_eq!(results.len(), 3);
assert!(results.iter().all(|x| x.outcome == Outcome::Pass));

// Check that the tests are run in parallel
let total_time = results.iter().flat_map(|result| result.time).sum();
assert!(execution_time < total_time);
}

#[test]
Expand Down

0 comments on commit 3e7514b

Please sign in to comment.