]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #103681 - RalfJung:libtest-thread, r=thomcc
authorMatthias Krüger <matthias.krueger@famsik.de>
Fri, 4 Nov 2022 17:52:26 +0000 (18:52 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Nov 2022 17:52:26 +0000 (18:52 +0100)
libtest: run all tests in their own thread, if supported by the host

This reverts the threading changes of https://github.com/rust-lang/rust/pull/56243, which made it so that with `-j1`, the test harness does not spawn any threads. Those changes were done to enable Miri to run the test harness, but Miri supports threads nowadays, so this is no longer needed. Using a thread for each test is useful because the thread's name can be set to the test's name which makes panic messages consistent between `-j1` and `-j2` runs and also a bit more readable.

I did not revert the HashMap changes of https://github.com/rust-lang/rust/pull/56243; using a deterministic map seems fine for the test harness and the more deterministic testing is the better.

Fixes https://github.com/rust-lang/rust/issues/59122
Fixes https://github.com/rust-lang/rust/issues/70492

1  2 
library/test/src/lib.rs

index f16d94bbc81c3fca9d9d7e597e74c607c064472d,a822df38e575808bb821fa763400fb41ecb086b3..27320e8dbc5ad42738fecaeea8131444bbc961f0
@@@ -440,11 -401,13 +439,13 @@@ wher
  
      if opts.bench_benchmarks {
          // All benchmarks run at the end, in serial.
 -        for (id, b) in filtered_benchs {
 +        for (id, b) in filtered.benchs {
              let event = TestEvent::TeWait(b.desc.clone());
              notify_about_test_event(event)?;
-             run_test(opts, false, id, b, run_strategy, tx.clone(), Concurrent::No);
-             let completed_test = rx.recv().unwrap();
+             let join_handle = run_test(opts, false, id, b, run_strategy, tx.clone());
+             // Wait for the test to complete.
+             let mut completed_test = rx.recv().unwrap();
+             RunningTest { join_handle }.join(&mut completed_test);
  
              let event = TestEvent::TeResult(completed_test);
              notify_about_test_event(event)?;