@@ -17,56 +17,22 @@ pub mod suites;
17
17
18
18
pub use self :: input:: Input ;
19
19
20
- pub trait TestFixture < T > {
20
+ pub trait TestFixture < T : std :: fmt :: Debug > {
21
21
fn test_cases ( ) -> Vec < T > ;
22
22
fn run ( test : & T ) ;
23
- }
24
-
25
- macro_rules! create_test {
26
- ( $name: expr, $should_panic: expr, $body: tt) => { {
27
- use rustc_test:: { TestDesc , TestDescAndFn , TestFn , TestName } ;
28
-
29
- TestDescAndFn {
30
- desc: TestDesc {
31
- name: TestName :: DynTestName ( $name) ,
32
- ignore: false ,
33
- should_panic: $should_panic,
34
- allow_fail: false ,
35
- } ,
36
- testfn: TestFn :: DynTestFn ( Box :: new( move || $body) ) ,
23
+ fn run_tests ( ) {
24
+ for test in Self :: test_cases ( ) {
25
+ let d = DumpOnPanic ( & test) ;
26
+ Self :: run ( & test) ;
27
+ std:: mem:: forget ( d) ;
37
28
}
38
- } } ;
29
+ }
39
30
}
40
31
41
- macro_rules! test_fixture {
42
- ( $fixture: ident) => {
43
- use rustc_test:: { ShouldPanic , TestDescAndFn } ;
44
-
45
- pub fn get_tests( ) -> Vec <TestDescAndFn > {
46
- $fixture:: test_cases( )
47
- . into_iter( )
48
- . map( |t| {
49
- create_test!( t. description. to_owned( ) , ShouldPanic :: No , {
50
- $fixture:: run( & t) ;
51
- } )
52
- } )
53
- . collect( )
54
- }
55
- } ;
32
+ struct DumpOnPanic < ' a , T : std:: fmt:: Debug > ( & ' a T ) ;
33
+ impl < T : std:: fmt:: Debug > Drop for DumpOnPanic < ' _ , T > {
34
+ fn drop ( & mut self ) {
35
+ eprintln ! ( "test case failed: {:?}" , self . 0 ) ;
36
+ }
56
37
}
57
38
58
- macro_rules! test_modules {
59
- ( $( $m: ident) ,+) => {
60
- $( mod $m; ) +
61
-
62
- use rustc_test:: TestDescAndFn ;
63
-
64
- pub fn get_tests( ) -> Vec <TestDescAndFn > {
65
- let mut tests = Vec :: default ( ) ;
66
-
67
- $( tests. extend( $m:: get_tests( ) ) ; ) +
68
-
69
- tests
70
- }
71
- } ;
72
- }
0 commit comments