9
9
// except according to those terms.
10
10
11
11
#![ crate_type = "lib" ]
12
-
13
- #![ cfg_attr( not( feature = "norustc" ) , feature( rustc_private) ) ]
14
- #![ cfg_attr( not( feature = "stable" ) , feature( test) ) ]
15
-
16
12
#![ deny( unused_imports) ]
13
+ #![ cfg_attr( feature = "unstable" , feature( rustc_private) ) ]
17
14
18
- #[ cfg( not ( feature = "norustc" ) ) ]
15
+ #[ cfg( feature = "unstable" ) ]
19
16
extern crate rustc;
20
17
21
18
#[ cfg( unix) ]
22
19
extern crate libc;
23
- extern crate libtest as test ;
20
+ extern crate libtest;
24
21
25
22
#[ cfg( feature = "tmp" ) ] extern crate tempfile;
26
23
@@ -84,7 +81,7 @@ pub fn run_tests(config: &Config) {
84
81
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
85
82
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
86
83
env:: set_var ( "__COMPAT_LAYER" , "RunAsInvoker" ) ;
87
- let res = test :: run_tests_console ( & opts, tests. into_iter ( ) . collect ( ) ) ;
84
+ let res = libtest :: run_tests_console ( & opts, tests. into_iter ( ) . collect ( ) ) ;
88
85
match res {
89
86
Ok ( true ) => { }
90
87
Ok ( false ) => panic ! ( "Some tests failed" ) ,
@@ -94,30 +91,30 @@ pub fn run_tests(config: &Config) {
94
91
}
95
92
}
96
93
97
- pub fn test_opts ( config : & Config ) -> test :: TestOpts {
98
- test :: TestOpts {
94
+ pub fn test_opts ( config : & Config ) -> libtest :: TestOpts {
95
+ libtest :: TestOpts {
99
96
filter : config. filter . clone ( ) ,
100
97
filter_exact : config. filter_exact ,
101
98
#[ cfg( not( feature = "stable" ) ) ]
102
99
exclude_should_panic : false ,
103
- run_ignored : if config. run_ignored { test :: RunIgnored :: Yes } else { test :: RunIgnored :: No } ,
104
- format : if config. quiet { test :: OutputFormat :: Terse } else { test :: OutputFormat :: Pretty } ,
100
+ run_ignored : if config. run_ignored { libtest :: RunIgnored :: Yes } else { libtest :: RunIgnored :: No } ,
101
+ format : if config. quiet { libtest :: OutputFormat :: Terse } else { libtest :: OutputFormat :: Pretty } ,
105
102
logfile : config. logfile . clone ( ) ,
106
103
run_tests : true ,
107
104
bench_benchmarks : true ,
108
105
nocapture : match env:: var ( "RUST_TEST_NOCAPTURE" ) {
109
106
Ok ( val) => & val != "0" ,
110
107
Err ( _) => false
111
108
} ,
112
- color : test :: AutoColor ,
109
+ color : libtest :: ColorChoice :: Auto ,
113
110
test_threads : None ,
114
111
skip : vec ! [ ] ,
115
112
list : false ,
116
- options : test :: Options :: new ( ) ,
113
+ options : libtest :: Options :: new ( ) ,
117
114
}
118
115
}
119
116
120
- pub fn make_tests ( config : & Config ) -> Vec < test :: TestDescAndFn > {
117
+ pub fn make_tests ( config : & Config ) -> Vec < libtest :: TestDescAndFn > {
121
118
debug ! ( "making tests from {:?}" ,
122
119
config. src_base. display( ) ) ;
123
120
let mut tests = Vec :: new ( ) ;
@@ -134,7 +131,7 @@ fn collect_tests_from_dir(config: &Config,
134
131
base : & Path ,
135
132
dir : & Path ,
136
133
relative_dir_path : & Path ,
137
- tests : & mut Vec < test :: TestDescAndFn > )
134
+ tests : & mut Vec < libtest :: TestDescAndFn > )
138
135
-> io:: Result < ( ) > {
139
136
// Ignore directories that contain a file
140
137
// `compiletest-ignore-dir`.
@@ -224,23 +221,23 @@ pub fn is_test(file_name: &OsString) -> bool {
224
221
!invalid_prefixes. iter ( ) . any ( |p| file_name. starts_with ( p) )
225
222
}
226
223
227
- pub fn make_test ( config : & Config , testpaths : & TestPaths ) -> test :: TestDescAndFn {
224
+ pub fn make_test ( config : & Config , testpaths : & TestPaths ) -> libtest :: TestDescAndFn {
228
225
let early_props = EarlyProps :: from_file ( config, & testpaths. file ) ;
229
226
230
227
// The `should-fail` annotation doesn't apply to pretty tests,
231
228
// since we run the pretty printer across all tests by default.
232
229
// If desired, we could add a `should-fail-pretty` annotation.
233
230
let should_panic = match config. mode {
234
- Pretty => test :: ShouldPanic :: No ,
231
+ Pretty => libtest :: ShouldPanic :: No ,
235
232
_ => if early_props. should_fail {
236
- test :: ShouldPanic :: Yes
233
+ libtest :: ShouldPanic :: Yes
237
234
} else {
238
- test :: ShouldPanic :: No
235
+ libtest :: ShouldPanic :: No
239
236
}
240
237
} ;
241
238
242
- test :: TestDescAndFn {
243
- desc : test :: TestDesc {
239
+ libtest :: TestDescAndFn {
240
+ desc : libtest :: TestDesc {
244
241
name : make_test_name ( config, testpaths) ,
245
242
ignore : early_props. ignore ,
246
243
should_panic : should_panic,
@@ -260,23 +257,22 @@ fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf {
260
257
. join ( stamp_name)
261
258
}
262
259
263
- pub fn make_test_name ( config : & Config , testpaths : & TestPaths ) -> test :: TestName {
260
+ pub fn make_test_name ( config : & Config , testpaths : & TestPaths ) -> libtest :: TestName {
264
261
// Convert a complete path to something like
265
262
//
266
263
// run-pass/foo/bar/baz.rs
267
264
let path =
268
265
PathBuf :: from ( config. src_base . file_name ( ) . unwrap ( ) )
269
266
. join ( & testpaths. relative_dir )
270
267
. join ( & testpaths. file . file_name ( ) . unwrap ( ) ) ;
271
- test :: DynTestName ( format ! ( "[{}] {}" , config. mode, path. display( ) ) )
268
+ libtest :: TestName :: DynTestName ( format ! ( "[{}] {}" , config. mode, path. display( ) ) )
272
269
}
273
270
274
- pub fn make_test_closure ( config : & Config , testpaths : & TestPaths ) -> test :: TestFn {
271
+ pub fn make_test_closure ( config : & Config , testpaths : & TestPaths ) -> libtest :: TestFn {
275
272
let config = config. clone ( ) ;
276
273
let testpaths = testpaths. clone ( ) ;
277
- test:: DynTestFn ( Box :: new ( move || {
278
- #[ cfg( feature = "stable" ) ]
279
- let config = config. clone ( ) ; // FIXME: why is this needed?
274
+ libtest:: TestFn :: DynTestFn ( Box :: new ( move || {
275
+ let config = config. clone ( ) ;
280
276
runtest:: run ( config, & testpaths)
281
277
} ) )
282
278
}
0 commit comments