@@ -40,7 +40,7 @@ pub mod test {
40
40
cli:: { parse_opts, TestOpts } ,
41
41
filter_tests,
42
42
helpers:: metrics:: { Metric , MetricMap } ,
43
- options:: { Concurrent , Options , RunIgnored , RunStrategy , ShouldPanic } ,
43
+ options:: { Options , RunIgnored , RunStrategy , ShouldPanic } ,
44
44
run_test, test_main, test_main_static,
45
45
test_result:: { TestResult , TrFailed , TrFailedMsg , TrIgnored , TrOk } ,
46
46
time:: { TestExecTime , TestTimeOptions } ,
@@ -85,7 +85,7 @@ use event::{CompletedTest, TestEvent};
85
85
use helpers:: concurrency:: get_concurrency;
86
86
use helpers:: exit_code:: get_exit_code;
87
87
use helpers:: shuffle:: { get_shuffle_seed, shuffle_tests} ;
88
- use options:: { Concurrent , RunStrategy } ;
88
+ use options:: RunStrategy ;
89
89
use test_result:: * ;
90
90
use time:: TestExecTime ;
91
91
@@ -235,6 +235,19 @@ where
235
235
join_handle : Option < thread:: JoinHandle < ( ) > > ,
236
236
}
237
237
238
+ impl RunningTest {
239
+ fn join ( self , completed_test : & mut CompletedTest ) {
240
+ if let Some ( join_handle) = self . join_handle {
241
+ if let Err ( _) = join_handle. join ( ) {
242
+ if let TrOk = completed_test. result {
243
+ completed_test. result =
244
+ TrFailedMsg ( "panicked after reporting success" . to_string ( ) ) ;
245
+ }
246
+ }
247
+ }
248
+ }
249
+ }
250
+
238
251
// Use a deterministic hasher
239
252
type TestMap =
240
253
HashMap < TestId , RunningTest , BuildHasherDefault < collections:: hash_map:: DefaultHasher > > ;
@@ -328,10 +341,10 @@ where
328
341
let ( id, test) = remaining. pop_front ( ) . unwrap ( ) ;
329
342
let event = TestEvent :: TeWait ( test. desc . clone ( ) ) ;
330
343
notify_about_test_event ( event) ?;
331
- let join_handle =
332
- run_test ( opts , !opts . run_tests , id , test, run_strategy , tx . clone ( ) , Concurrent :: No ) ;
333
- assert ! ( join_handle . is_none ( ) ) ;
334
- let completed_test = rx . recv ( ) . unwrap ( ) ;
344
+ let join_handle = run_test ( opts , !opts . run_tests , id , test , run_strategy , tx . clone ( ) ) ;
345
+ // Wait for the test to complete.
346
+ let mut completed_test = rx . recv ( ) . unwrap ( ) ;
347
+ RunningTest { join_handle } . join ( & mut completed_test ) ;
335
348
336
349
let event = TestEvent :: TeResult ( completed_test) ;
337
350
notify_about_test_event ( event) ?;
@@ -345,15 +358,8 @@ where
345
358
346
359
let event = TestEvent :: TeWait ( desc. clone ( ) ) ;
347
360
notify_about_test_event ( event) ?; //here no pad
348
- let join_handle = run_test (
349
- opts,
350
- !opts. run_tests ,
351
- id,
352
- test,
353
- run_strategy,
354
- tx. clone ( ) ,
355
- Concurrent :: Yes ,
356
- ) ;
361
+ let join_handle =
362
+ run_test ( opts, !opts. run_tests , id, test, run_strategy, tx. clone ( ) ) ;
357
363
running_tests. insert ( id, RunningTest { join_handle } ) ;
358
364
timeout_queue. push_back ( TimeoutEntry { id, desc, timeout } ) ;
359
365
pending += 1 ;
@@ -385,14 +391,7 @@ where
385
391
386
392
let mut completed_test = res. unwrap ( ) ;
387
393
let running_test = running_tests. remove ( & completed_test. id ) . unwrap ( ) ;
388
- if let Some ( join_handle) = running_test. join_handle {
389
- if let Err ( _) = join_handle. join ( ) {
390
- if let TrOk = completed_test. result {
391
- completed_test. result =
392
- TrFailedMsg ( "panicked after reporting success" . to_string ( ) ) ;
393
- }
394
- }
395
- }
394
+ running_test. join ( & mut completed_test) ;
396
395
397
396
let event = TestEvent :: TeResult ( completed_test) ;
398
397
notify_about_test_event ( event) ?;
@@ -405,8 +404,10 @@ where
405
404
for ( id, b) in filtered_benchs {
406
405
let event = TestEvent :: TeWait ( b. desc . clone ( ) ) ;
407
406
notify_about_test_event ( event) ?;
408
- run_test ( opts, false , id, b, run_strategy, tx. clone ( ) , Concurrent :: No ) ;
409
- let completed_test = rx. recv ( ) . unwrap ( ) ;
407
+ let join_handle = run_test ( opts, false , id, b, run_strategy, tx. clone ( ) ) ;
408
+ // Wait for the test to complete.
409
+ let mut completed_test = rx. recv ( ) . unwrap ( ) ;
410
+ RunningTest { join_handle } . join ( & mut completed_test) ;
410
411
411
412
let event = TestEvent :: TeResult ( completed_test) ;
412
413
notify_about_test_event ( event) ?;
@@ -480,7 +481,6 @@ pub fn run_test(
480
481
test : TestDescAndFn ,
481
482
strategy : RunStrategy ,
482
483
monitor_ch : Sender < CompletedTest > ,
483
- concurrency : Concurrent ,
484
484
) -> Option < thread:: JoinHandle < ( ) > > {
485
485
let TestDescAndFn { desc, testfn } = test;
486
486
@@ -498,7 +498,6 @@ pub fn run_test(
498
498
struct TestRunOpts {
499
499
pub strategy : RunStrategy ,
500
500
pub nocapture : bool ,
501
- pub concurrency : Concurrent ,
502
501
pub time : Option < time:: TestTimeOptions > ,
503
502
}
504
503
@@ -509,7 +508,6 @@ pub fn run_test(
509
508
testfn : Box < dyn FnOnce ( ) -> Result < ( ) , String > + Send > ,
510
509
opts : TestRunOpts ,
511
510
) -> Option < thread:: JoinHandle < ( ) > > {
512
- let concurrency = opts. concurrency ;
513
511
let name = desc. name . clone ( ) ;
514
512
515
513
let runtest = move || match opts. strategy {
@@ -536,7 +534,7 @@ pub fn run_test(
536
534
// the test synchronously, regardless of the concurrency
537
535
// level.
538
536
let supports_threads = !cfg ! ( target_os = "emscripten" ) && !cfg ! ( target_family = "wasm" ) ;
539
- if concurrency == Concurrent :: Yes && supports_threads {
537
+ if supports_threads {
540
538
let cfg = thread:: Builder :: new ( ) . name ( name. as_slice ( ) . to_owned ( ) ) ;
541
539
let mut runtest = Arc :: new ( Mutex :: new ( Some ( runtest) ) ) ;
542
540
let runtest2 = runtest. clone ( ) ;
@@ -557,7 +555,7 @@ pub fn run_test(
557
555
}
558
556
559
557
let test_run_opts =
560
- TestRunOpts { strategy, nocapture : opts. nocapture , concurrency , time : opts. time_options } ;
558
+ TestRunOpts { strategy, nocapture : opts. nocapture , time : opts. time_options } ;
561
559
562
560
match testfn {
563
561
DynBenchFn ( benchfn) => {
0 commit comments