@@ -54,14 +54,15 @@ pub fn run(input: &str,
54
54
libs : SearchPaths ,
55
55
externs : Externs ,
56
56
mut test_args : Vec < String > ,
57
- crate_name : Option < String > )
57
+ crate_name : Option < String > ,
58
+ maybe_sysroot : Option < PathBuf > )
58
59
-> isize {
59
60
let input_path = PathBuf :: from ( input) ;
60
61
let input = config:: Input :: File ( input_path. clone ( ) ) ;
61
62
62
63
let sessopts = config:: Options {
63
- maybe_sysroot : Some ( env :: current_exe ( ) . unwrap ( ) . parent ( ) . unwrap ( )
64
- . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ,
64
+ maybe_sysroot : maybe_sysroot . clone ( ) . or_else (
65
+ || Some ( env :: current_exe ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ) ,
65
66
search_paths : libs. clone ( ) ,
66
67
crate_types : vec ! [ config:: CrateTypeDylib ] ,
67
68
externs : externs. clone ( ) ,
@@ -99,7 +100,8 @@ pub fn run(input: &str,
99
100
libs,
100
101
externs,
101
102
false ,
102
- opts) ;
103
+ opts,
104
+ maybe_sysroot) ;
103
105
104
106
{
105
107
let dep_graph = DepGraph :: new ( false ) ;
@@ -157,7 +159,8 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
157
159
fn runtest ( test : & str , cratename : & str , cfgs : Vec < String > , libs : SearchPaths ,
158
160
externs : Externs ,
159
161
should_panic : bool , no_run : bool , as_test_harness : bool ,
160
- compile_fail : bool , mut error_codes : Vec < String > , opts : & TestOptions ) {
162
+ compile_fail : bool , mut error_codes : Vec < String > , opts : & TestOptions ,
163
+ maybe_sysroot : Option < PathBuf > ) {
161
164
// the test harness wants its own `main` & top level functions, so
162
165
// never wrap the test in `fn main() { ... }`
163
166
let test = maketest ( test, Some ( cratename) , as_test_harness, opts) ;
@@ -168,8 +171,8 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
168
171
let outputs = OutputTypes :: new ( & [ ( OutputType :: Exe , None ) ] ) ;
169
172
170
173
let sessopts = config:: Options {
171
- maybe_sysroot : Some ( env :: current_exe ( ) . unwrap ( ) . parent ( ) . unwrap ( )
172
- . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ,
174
+ maybe_sysroot : maybe_sysroot . or_else (
175
+ || Some ( env :: current_exe ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ) ,
173
176
search_paths : libs,
174
177
crate_types : vec ! [ config:: CrateTypeExecutable ] ,
175
178
output_types : outputs,
@@ -379,11 +382,12 @@ pub struct Collector {
379
382
current_header : Option < String > ,
380
383
cratename : String ,
381
384
opts : TestOptions ,
385
+ maybe_sysroot : Option < PathBuf > ,
382
386
}
383
387
384
388
impl Collector {
385
389
pub fn new ( cratename : String , cfgs : Vec < String > , libs : SearchPaths , externs : Externs ,
386
- use_headers : bool , opts : TestOptions ) -> Collector {
390
+ use_headers : bool , opts : TestOptions , maybe_sysroot : Option < PathBuf > ) -> Collector {
387
391
Collector {
388
392
tests : Vec :: new ( ) ,
389
393
names : Vec :: new ( ) ,
@@ -395,6 +399,7 @@ impl Collector {
395
399
current_header : None ,
396
400
cratename : cratename,
397
401
opts : opts,
402
+ maybe_sysroot : maybe_sysroot,
398
403
}
399
404
}
400
405
@@ -413,6 +418,7 @@ impl Collector {
413
418
let externs = self . externs . clone ( ) ;
414
419
let cratename = self . cratename . to_string ( ) ;
415
420
let opts = self . opts . clone ( ) ;
421
+ let maybe_sysroot = self . maybe_sysroot . clone ( ) ;
416
422
debug ! ( "Creating test {}: {}" , name, test) ;
417
423
self . tests . push ( testing:: TestDescAndFn {
418
424
desc : testing:: TestDesc {
@@ -432,7 +438,8 @@ impl Collector {
432
438
as_test_harness,
433
439
compile_fail,
434
440
error_codes,
435
- & opts) ;
441
+ & opts,
442
+ maybe_sysroot) ;
436
443
} )
437
444
} ) ;
438
445
}
0 commit comments