1
1
// Code that generates a test runner to run all the tests in a crate
2
2
3
- #![ allow( dead_code) ]
4
- #![ allow( unused_imports) ]
5
-
6
- use HasTestSignature :: * ;
7
-
8
- use std:: iter;
9
- use std:: slice;
10
- use std:: mem;
11
- use std:: vec;
12
-
13
3
use log:: debug;
14
4
use smallvec:: { smallvec, SmallVec } ;
15
- use syntax_pos:: { DUMMY_SP , NO_EXPANSION , Span , SourceFile , BytePos } ;
16
-
17
- use crate :: attr:: { self , HasAttrs } ;
18
- use crate :: source_map:: { self , SourceMap , ExpnInfo , ExpnKind , dummy_spanned, respan} ;
19
- use crate :: config;
20
- use crate :: entry:: { self , EntryPointType } ;
21
- use crate :: ext:: base:: { ExtCtxt , Resolver } ;
22
- use crate :: ext:: build:: AstBuilder ;
23
- use crate :: ext:: expand:: ExpansionConfig ;
24
- use crate :: ext:: hygiene:: { self , ExpnId , SyntaxContext , MacroKind } ;
25
- use crate :: mut_visit:: { * , ExpectOne } ;
26
- use crate :: feature_gate:: Features ;
27
- use crate :: util:: map_in_place:: MapInPlace ;
28
- use crate :: parse:: { token, ParseSess } ;
29
- use crate :: ast:: { self , Ident } ;
30
- use crate :: ptr:: P ;
31
- use crate :: symbol:: { self , Symbol , kw, sym} ;
32
- use crate :: ThinVec ;
5
+ use syntax:: ast:: { self , Ident } ;
6
+ use syntax:: attr;
7
+ use syntax:: entry:: { self , EntryPointType } ;
8
+ use syntax:: ext:: base:: { ExtCtxt , Resolver } ;
9
+ use syntax:: ext:: build:: AstBuilder ;
10
+ use syntax:: ext:: expand:: ExpansionConfig ;
11
+ use syntax:: ext:: hygiene:: { ExpnId , MacroKind } ;
12
+ use syntax:: feature_gate:: Features ;
13
+ use syntax:: mut_visit:: { * , ExpectOne } ;
14
+ use syntax:: parse:: ParseSess ;
15
+ use syntax:: ptr:: P ;
16
+ use syntax:: source_map:: { ExpnInfo , ExpnKind , dummy_spanned} ;
17
+ use syntax:: symbol:: { kw, sym, Symbol } ;
18
+ use syntax_pos:: { Span , DUMMY_SP } ;
19
+
20
+ use std:: { iter, mem} ;
33
21
34
22
struct Test {
35
23
span : Span ,
@@ -42,10 +30,7 @@ struct TestCtxt<'a> {
42
30
ext_cx : ExtCtxt < ' a > ,
43
31
test_cases : Vec < Test > ,
44
32
reexport_test_harness_main : Option < Symbol > ,
45
- is_libtest : bool ,
46
- features : & ' a Features ,
47
33
test_runner : Option < ast:: Path > ,
48
-
49
34
// top-level re-export submodule, filled out after folding is finished
50
35
toplevel_reexport : Option < Ident > ,
51
36
}
@@ -267,11 +252,7 @@ fn generate_test_harness(sess: &ParseSess,
267
252
path : Vec :: new ( ) ,
268
253
test_cases : Vec :: new ( ) ,
269
254
reexport_test_harness_main,
270
- // N.B., doesn't consider the value of `--crate-name` passed on the command line.
271
- is_libtest : attr:: find_crate_name ( & krate. attrs )
272
- . map ( |s| s == sym:: test) . unwrap_or ( false ) ,
273
255
toplevel_reexport : None ,
274
- features,
275
256
test_runner
276
257
} ;
277
258
@@ -282,19 +263,6 @@ fn generate_test_harness(sess: &ParseSess,
282
263
} . visit_crate ( krate) ;
283
264
}
284
265
285
- enum HasTestSignature {
286
- Yes ,
287
- No ( BadTestSignature ) ,
288
- }
289
-
290
- #[ derive( PartialEq ) ]
291
- enum BadTestSignature {
292
- NotEvenAFunction ,
293
- WrongTypeSignature ,
294
- NoArgumentsAllowed ,
295
- ShouldPanicOnlyWithNoArgs ,
296
- }
297
-
298
266
/// Creates a function item for use as the main function of a test build.
299
267
/// This function will call the `test_runner` as specified by the crate attribute
300
268
fn mk_main ( cx : & mut TestCtxt < ' _ > ) -> P < ast:: Item > {
0 commit comments