4
4
#![ allow( clippy:: integer_arithmetic) ]
5
5
6
6
use crate :: { utils, Result } ;
7
- use libtest_mimic:: { run_tests , Arguments , Outcome , Test } ;
7
+ use libtest_mimic:: { Arguments , Trial } ;
8
8
use std:: path:: Path ;
9
9
10
10
#[ doc( hidden) ]
11
11
pub fn runner ( requirements : & [ Requirements ] ) {
12
12
let args = Arguments :: from_args ( ) ;
13
13
14
14
let mut tests: Vec < _ > = requirements. iter ( ) . flat_map ( |req| req. expand ( ) ) . collect ( ) ;
15
- tests. sort_unstable_by ( |a, b| a. name . cmp ( & b. name ) ) ;
15
+ tests. sort_unstable_by ( |a, b| a. name ( ) . cmp ( b. name ( ) ) ) ;
16
16
17
- run_tests ( & args, tests, |test| ( test . data ) ( ) ) . exit ( )
17
+ libtest_mimic :: run ( & args, tests) . exit ( )
18
18
}
19
19
20
20
#[ doc( hidden) ]
@@ -43,7 +43,7 @@ impl Requirements {
43
43
44
44
/// Scans all files in a given directory, finds matching ones and generates a test descriptor
45
45
/// for each of them.
46
- fn expand ( & self ) -> Vec < Test < Box < dyn Fn ( ) -> Outcome + Send + Sync > > > {
46
+ fn expand ( & self ) -> Vec < Trial > {
47
47
let root = Path :: new ( & self . root ) . to_path_buf ( ) ;
48
48
49
49
let re = regex:: Regex :: new ( & self . pattern )
@@ -55,21 +55,10 @@ impl Requirements {
55
55
if re. is_match ( & input_path) {
56
56
let testfn = self . test ;
57
57
let name = utils:: derive_test_name ( & root, & path, & self . test_name ) ;
58
- let testfn: Box < dyn Fn ( ) -> Outcome + Send + Sync > =
59
- Box :: new ( move || match ( testfn) ( & path) {
60
- Ok ( ( ) ) => Outcome :: Passed ,
61
- Err ( err) => Outcome :: Failed {
62
- msg : Some ( format ! ( "{}" , err) ) ,
63
- } ,
64
- } ) ;
65
58
66
- Some ( Test {
67
- name,
68
- kind : String :: new ( ) ,
69
- is_ignored : false ,
70
- is_bench : false ,
71
- data : testfn,
72
- } )
59
+ Some ( Trial :: test ( name, move || {
60
+ ( testfn) ( & path) . map_err ( Into :: into)
61
+ } ) )
73
62
} else {
74
63
None
75
64
}
0 commit comments