13
13
//! This file implements the various regression test suites that we execute on
14
14
//! our CI.
15
15
16
- extern crate build_helper;
17
-
18
16
use std:: collections:: HashSet ;
19
17
use std:: env;
18
+ use std:: iter;
20
19
use std:: fmt;
21
20
use std:: fs:: { self , File } ;
22
21
use std:: path:: { PathBuf , Path } ;
23
22
use std:: process:: Command ;
24
23
use std:: io:: Read ;
25
24
26
- use build_helper:: output;
25
+ use build_helper:: { self , output} ;
27
26
28
27
use { Build , Compiler , Mode } ;
29
28
use dist;
30
29
use util:: { self , dylib_path, dylib_path_var, exe} ;
31
30
32
- const ADB_TEST_DIR : & ' static str = "/data/tmp/work" ;
31
+ const ADB_TEST_DIR : & str = "/data/tmp/work" ;
33
32
34
33
/// The two modes of the test runner; tests or benchmarks.
35
34
#[ derive( Copy , Clone ) ]
@@ -60,7 +59,7 @@ impl fmt::Display for TestKind {
60
59
}
61
60
62
61
fn try_run ( build : & Build , cmd : & mut Command ) {
63
- if build. flags . cmd . no_fail_fast ( ) {
62
+ if ! build. fail_fast {
64
63
if !build. try_run ( cmd) {
65
64
let failures = build. delayed_failures . get ( ) ;
66
65
build. delayed_failures . set ( failures + 1 ) ;
@@ -71,7 +70,7 @@ fn try_run(build: &Build, cmd: &mut Command) {
71
70
}
72
71
73
72
fn try_run_quiet ( build : & Build , cmd : & mut Command ) {
74
- if build. flags . cmd . no_fail_fast ( ) {
73
+ if ! build. fail_fast {
75
74
if !build. try_run_quiet ( cmd) {
76
75
let failures = build. delayed_failures . get ( ) ;
77
76
build. delayed_failures . set ( failures + 1 ) ;
@@ -99,7 +98,7 @@ pub fn linkcheck(build: &Build, host: &str) {
99
98
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
100
99
/// test` to ensure that we don't regress the test suites there.
101
100
pub fn cargotest ( build : & Build , stage : u32 , host : & str ) {
102
- let ref compiler = Compiler :: new ( stage, host) ;
101
+ let compiler = Compiler :: new ( stage, host) ;
103
102
104
103
// Note that this is a short, cryptic, and not scoped directory name. This
105
104
// is currently to minimize the length of path on Windows where we otherwise
@@ -109,11 +108,11 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
109
108
110
109
let _time = util:: timeit ( ) ;
111
110
let mut cmd = Command :: new ( build. tool ( & Compiler :: new ( 0 , host) , "cargotest" ) ) ;
112
- build. prepare_tool_cmd ( compiler, & mut cmd) ;
113
- try_run ( build, cmd. arg ( & build. cargo )
111
+ build. prepare_tool_cmd ( & compiler, & mut cmd) ;
112
+ try_run ( build, cmd. arg ( & build. initial_cargo )
114
113
. arg ( & out_dir)
115
- . env ( "RUSTC" , build. compiler_path ( compiler) )
116
- . env ( "RUSTDOC" , build. rustdoc ( compiler) ) ) ;
114
+ . env ( "RUSTC" , build. compiler_path ( & compiler) )
115
+ . env ( "RUSTDOC" , build. rustdoc ( & compiler) ) ) ;
117
116
}
118
117
119
118
/// Runs `cargo test` for `cargo` packaged with Rust.
@@ -124,13 +123,12 @@ pub fn cargo(build: &Build, stage: u32, host: &str) {
124
123
// and not RUSTC because the Cargo test suite has tests that will
125
124
// fail if rustc is not spelled `rustc`.
126
125
let path = build. sysroot ( compiler) . join ( "bin" ) ;
127
- let old_path = :: std:: env:: var ( "PATH" ) . expect ( "" ) ;
128
- let sep = if cfg ! ( windows) { ";" } else { ":" } ;
129
- let ref newpath = format ! ( "{}{}{}" , path. display( ) , sep, old_path) ;
126
+ let old_path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
127
+ let newpath = env:: join_paths ( iter:: once ( path) . chain ( env:: split_paths ( & old_path) ) ) . expect ( "" ) ;
130
128
131
129
let mut cargo = build. cargo ( compiler, Mode :: Tool , host, "test" ) ;
132
130
cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/cargo/Cargo.toml" ) ) ;
133
- if build. flags . cmd . no_fail_fast ( ) {
131
+ if ! build. fail_fast {
134
132
cargo. arg ( "--no-fail-fast" ) ;
135
133
}
136
134
@@ -198,9 +196,9 @@ pub fn compiletest(build: &Build,
198
196
cmd. arg ( "--mode" ) . arg ( mode) ;
199
197
cmd. arg ( "--target" ) . arg ( target) ;
200
198
cmd. arg ( "--host" ) . arg ( compiler. host ) ;
201
- cmd. arg ( "--llvm-filecheck" ) . arg ( build. llvm_filecheck ( & build. config . build ) ) ;
199
+ cmd. arg ( "--llvm-filecheck" ) . arg ( build. llvm_filecheck ( & build. build ) ) ;
202
200
203
- if let Some ( nodejs) = build. config . nodejs . as_ref ( ) {
201
+ if let Some ( ref nodejs) = build. config . nodejs {
204
202
cmd. arg ( "--nodejs" ) . arg ( nodejs) ;
205
203
}
206
204
@@ -224,7 +222,7 @@ pub fn compiletest(build: &Build,
224
222
225
223
cmd. arg ( "--docck-python" ) . arg ( build. python ( ) ) ;
226
224
227
- if build. config . build . ends_with ( "apple-darwin" ) {
225
+ if build. build . ends_with ( "apple-darwin" ) {
228
226
// Force /usr/bin/python on macOS for LLDB tests because we're loading the
229
227
// LLDB plugin's compiled module which only works with the system python
230
228
// (namely not Homebrew-installed python)
@@ -251,7 +249,7 @@ pub fn compiletest(build: &Build,
251
249
252
250
cmd. args ( & build. flags . cmd . test_args ( ) ) ;
253
251
254
- if build. config . verbose ( ) || build . flags . verbose ( ) {
252
+ if build. is_verbose ( ) {
255
253
cmd. arg ( "--verbose" ) ;
256
254
}
257
255
@@ -279,7 +277,7 @@ pub fn compiletest(build: &Build,
279
277
280
278
if build. remote_tested ( target) {
281
279
cmd. arg ( "--remote-test-client" )
282
- . arg ( build. tool ( & Compiler :: new ( 0 , & build. config . build ) ,
280
+ . arg ( build. tool ( & Compiler :: new ( 0 , & build. build ) ,
283
281
"remote-test-client" ) ) ;
284
282
}
285
283
@@ -368,7 +366,7 @@ pub fn error_index(build: &Build, compiler: &Compiler) {
368
366
"error_index_generator" )
369
367
. arg ( "markdown" )
370
368
. arg ( & output)
371
- . env ( "CFG_BUILD" , & build. config . build ) ) ;
369
+ . env ( "CFG_BUILD" , & build. build ) ) ;
372
370
373
371
markdown_test ( build, compiler, & output) ;
374
372
}
@@ -450,7 +448,7 @@ pub fn krate(build: &Build,
450
448
cargo. arg ( "--manifest-path" )
451
449
. arg ( build. src . join ( path) . join ( "Cargo.toml" ) )
452
450
. arg ( "--features" ) . arg ( features) ;
453
- if test_kind. subcommand ( ) == "test" && build. flags . cmd . no_fail_fast ( ) {
451
+ if test_kind. subcommand ( ) == "test" && ! build. fail_fast {
454
452
cargo. arg ( "--no-fail-fast" ) ;
455
453
}
456
454
@@ -520,16 +518,14 @@ fn krate_emscripten(build: &Build,
520
518
compiler : & Compiler ,
521
519
target : & str ,
522
520
mode : Mode ) {
523
- let mut tests = Vec :: new ( ) ;
524
521
let out_dir = build. cargo_out ( compiler, mode, target) ;
525
- find_tests ( & out_dir. join ( "deps" ) , target, & mut tests ) ;
522
+ let tests = find_tests ( & out_dir. join ( "deps" ) , target) ;
526
523
524
+ let nodejs = build. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ;
527
525
for test in tests {
528
- let test_file_name = test. to_string_lossy ( ) . into_owned ( ) ;
529
- println ! ( "running {}" , test_file_name) ;
530
- let nodejs = build. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ;
526
+ println ! ( "running {}" , test. display( ) ) ;
531
527
let mut cmd = Command :: new ( nodejs) ;
532
- cmd. arg ( & test_file_name ) ;
528
+ cmd. arg ( & test ) ;
533
529
if build. config . quiet_tests {
534
530
cmd. arg ( "--quiet" ) ;
535
531
}
@@ -541,11 +537,10 @@ fn krate_remote(build: &Build,
541
537
compiler : & Compiler ,
542
538
target : & str ,
543
539
mode : Mode ) {
544
- let mut tests = Vec :: new ( ) ;
545
540
let out_dir = build. cargo_out ( compiler, mode, target) ;
546
- find_tests ( & out_dir. join ( "deps" ) , target, & mut tests ) ;
541
+ let tests = find_tests ( & out_dir. join ( "deps" ) , target) ;
547
542
548
- let tool = build. tool ( & Compiler :: new ( 0 , & build. config . build ) ,
543
+ let tool = build. tool ( & Compiler :: new ( 0 , & build. build ) ,
549
544
"remote-test-client" ) ;
550
545
for test in tests {
551
546
let mut cmd = Command :: new ( & tool) ;
@@ -559,9 +554,8 @@ fn krate_remote(build: &Build,
559
554
}
560
555
}
561
556
562
- fn find_tests ( dir : & Path ,
563
- target : & str ,
564
- dst : & mut Vec < PathBuf > ) {
557
+ fn find_tests ( dir : & Path , target : & str ) -> Vec < PathBuf > {
558
+ let mut dst = Vec :: new ( ) ;
565
559
for e in t ! ( dir. read_dir( ) ) . map ( |e| t ! ( e) ) {
566
560
let file_type = t ! ( e. file_type( ) ) ;
567
561
if !file_type. is_file ( ) {
@@ -576,6 +570,7 @@ fn find_tests(dir: &Path,
576
570
dst. push ( e. path ( ) ) ;
577
571
}
578
572
}
573
+ dst
579
574
}
580
575
581
576
pub fn remote_copy_libs ( build : & Build , compiler : & Compiler , target : & str ) {
@@ -590,7 +585,7 @@ pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
590
585
. join ( exe ( "remote-test-server" , target) ) ;
591
586
592
587
// Spawn the emulator and wait for it to come online
593
- let tool = build. tool ( & Compiler :: new ( 0 , & build. config . build ) ,
588
+ let tool = build. tool ( & Compiler :: new ( 0 , & build. build ) ,
594
589
"remote-test-client" ) ;
595
590
let mut cmd = Command :: new ( & tool) ;
596
591
cmd. arg ( "spawn-emulator" )
@@ -616,7 +611,7 @@ pub fn remote_copy_libs(build: &Build, compiler: &Compiler, target: &str) {
616
611
617
612
/// Run "distcheck", a 'make check' from a tarball
618
613
pub fn distcheck ( build : & Build ) {
619
- if build. config . build != "x86_64-unknown-linux-gnu" {
614
+ if build. build != "x86_64-unknown-linux-gnu" {
620
615
return
621
616
}
622
617
if !build. config . host . iter ( ) . any ( |s| s == "x86_64-unknown-linux-gnu" ) {
@@ -641,7 +636,7 @@ pub fn distcheck(build: &Build) {
641
636
. args ( & build. config . configure_args )
642
637
. arg ( "--enable-vendor" )
643
638
. current_dir ( & dir) ) ;
644
- build. run ( Command :: new ( build_helper:: make ( & build. config . build ) )
639
+ build. run ( Command :: new ( build_helper:: make ( & build. build ) )
645
640
. arg ( "check" )
646
641
. current_dir ( & dir) ) ;
647
642
@@ -659,7 +654,7 @@ pub fn distcheck(build: &Build) {
659
654
build. run ( & mut cmd) ;
660
655
661
656
let toml = dir. join ( "rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml" ) ;
662
- build. run ( Command :: new ( & build. cargo )
657
+ build. run ( Command :: new ( & build. initial_cargo )
663
658
. arg ( "generate-lockfile" )
664
659
. arg ( "--manifest-path" )
665
660
. arg ( & toml)
@@ -668,13 +663,13 @@ pub fn distcheck(build: &Build) {
668
663
669
664
/// Test the build system itself
670
665
pub fn bootstrap ( build : & Build ) {
671
- let mut cmd = Command :: new ( & build. cargo ) ;
666
+ let mut cmd = Command :: new ( & build. initial_cargo ) ;
672
667
cmd. arg ( "test" )
673
668
. current_dir ( build. src . join ( "src/bootstrap" ) )
674
669
. env ( "CARGO_TARGET_DIR" , build. out . join ( "bootstrap" ) )
675
670
. env ( "RUSTC_BOOTSTRAP" , "1" )
676
- . env ( "RUSTC" , & build. rustc ) ;
677
- if build. flags . cmd . no_fail_fast ( ) {
671
+ . env ( "RUSTC" , & build. initial_rustc ) ;
672
+ if ! build. fail_fast {
678
673
cmd. arg ( "--no-fail-fast" ) ;
679
674
}
680
675
cmd. arg ( "--" ) . args ( & build. flags . cmd . test_args ( ) ) ;
0 commit comments