@@ -2102,8 +2102,13 @@ impl Step for CrateLibrustc {
2102
2102
}
2103
2103
2104
2104
// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
2105
- fn cargo_test_args ( cargo : & mut Command , libtest_args : & [ & str ] , _crates : & [ & str ] , builder : & Builder < ' _ > ) {
2106
- if !builder. fail_fast {
2105
+ fn run_cargo_test ( cargo : impl Into < Command > , libtest_args : & [ & str ] , crates : & [ Interned < String > ] , compiler : Compiler , target : TargetSelection , builder : & Builder < ' _ > ) {
2106
+ let mut cargo = cargo. into ( ) ;
2107
+
2108
+ // Pass in some standard flags then iterate over the graph we've discovered
2109
+ // in `cargo metadata` with the maps above and figure out what `-p`
2110
+ // arguments need to get passed.
2111
+ if builder. kind == Kind :: Test && !builder. fail_fast {
2107
2112
cargo. arg ( "--no-fail-fast" ) ;
2108
2113
}
2109
2114
match builder. doc_tests {
@@ -2116,8 +2121,38 @@ fn cargo_test_args(cargo: &mut Command, libtest_args: &[&str], _crates: &[&str],
2116
2121
DocTests :: Yes => { }
2117
2122
}
2118
2123
2124
+ for & krate in crates {
2125
+ cargo. arg ( "-p" ) . arg ( krate) ;
2126
+ }
2127
+
2128
+ // The tests are going to run with the *target* libraries, so we need to
2129
+ // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
2130
+ //
2131
+ // Note that to run the compiler we need to run with the *host* libraries,
2132
+ // but our wrapper scripts arrange for that to be the case anyway.
2133
+ let mut dylib_path = dylib_path ( ) ;
2134
+ dylib_path. insert ( 0 , PathBuf :: from ( & * builder. sysroot_libdir ( compiler, target) ) ) ;
2135
+ cargo. env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
2136
+
2137
+ if target. contains ( "emscripten" ) {
2138
+ cargo. env (
2139
+ format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) ,
2140
+ builder. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ,
2141
+ ) ;
2142
+ } else if target. starts_with ( "wasm32" ) {
2143
+ let node = builder. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ;
2144
+ let runner = format ! ( "{} {}/src/etc/wasm32-shim.js" , node. display( ) , builder. src. display( ) ) ;
2145
+ cargo. env ( format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) , & runner) ;
2146
+ } else if builder. remote_tested ( target) {
2147
+ cargo. env (
2148
+ format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) ,
2149
+ format ! ( "{} run 0" , builder. tool_exe( Tool :: RemoteTestClient ) . display( ) ) ,
2150
+ ) ;
2151
+ }
2152
+
2119
2153
cargo. arg ( "--" ) . args ( & builder. config . cmd . test_args ( ) ) . args ( libtest_args) ;
2120
- add_flags_and_try_run_tests ( builder, cargo) ;
2154
+ let _time = util:: timeit ( & builder) ;
2155
+ add_flags_and_try_run_tests ( builder, & mut cargo) ;
2121
2156
}
2122
2157
2123
2158
#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -2183,60 +2218,6 @@ impl Step for Crate {
2183
2218
_ => panic ! ( "can only test libraries" ) ,
2184
2219
} ;
2185
2220
2186
- // Build up the base `cargo test` command.
2187
- //
2188
- // Pass in some standard flags then iterate over the graph we've discovered
2189
- // in `cargo metadata` with the maps above and figure out what `-p`
2190
- // arguments need to get passed.
2191
- if builder. kind == Kind :: Test && !builder. fail_fast {
2192
- cargo. arg ( "--no-fail-fast" ) ;
2193
- }
2194
- match builder. doc_tests {
2195
- DocTests :: Only => {
2196
- cargo. arg ( "--doc" ) ;
2197
- }
2198
- DocTests :: No => {
2199
- cargo. args ( & [ "--lib" , "--bins" , "--examples" , "--tests" , "--benches" ] ) ;
2200
- }
2201
- DocTests :: Yes => { }
2202
- }
2203
-
2204
- for krate in & self . crates {
2205
- cargo. arg ( "-p" ) . arg ( krate) ;
2206
- }
2207
-
2208
- // The tests are going to run with the *target* libraries, so we need to
2209
- // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
2210
- //
2211
- // Note that to run the compiler we need to run with the *host* libraries,
2212
- // but our wrapper scripts arrange for that to be the case anyway.
2213
- let mut dylib_path = dylib_path ( ) ;
2214
- dylib_path. insert ( 0 , PathBuf :: from ( & * builder. sysroot_libdir ( compiler, target) ) ) ;
2215
- cargo. env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
2216
-
2217
- cargo. arg ( "--" ) ;
2218
- cargo. args ( & builder. config . cmd . test_args ( ) ) ;
2219
-
2220
- cargo. arg ( "-Z" ) . arg ( "unstable-options" ) ;
2221
- cargo. arg ( "--format" ) . arg ( "json" ) ;
2222
-
2223
- if target. contains ( "emscripten" ) {
2224
- cargo. env (
2225
- format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) ,
2226
- builder. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ,
2227
- ) ;
2228
- } else if target. starts_with ( "wasm32" ) {
2229
- let node = builder. config . nodejs . as_ref ( ) . expect ( "nodejs not configured" ) ;
2230
- let runner =
2231
- format ! ( "{} {}/src/etc/wasm32-shim.js" , node. display( ) , builder. src. display( ) ) ;
2232
- cargo. env ( format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) , & runner) ;
2233
- } else if builder. remote_tested ( target) {
2234
- cargo. env (
2235
- format ! ( "CARGO_TARGET_{}_RUNNER" , envify( & target. triple) ) ,
2236
- format ! ( "{} run 0" , builder. tool_exe( Tool :: RemoteTestClient ) . display( ) ) ,
2237
- ) ;
2238
- }
2239
-
2240
2221
builder. info ( & format ! (
2241
2222
"{}{} stage{} ({} -> {})" ,
2242
2223
builder. kind. test_description( ) ,
@@ -2245,8 +2226,7 @@ impl Step for Crate {
2245
2226
& compiler. host,
2246
2227
target
2247
2228
) ) ;
2248
- let _time = util:: timeit ( & builder) ;
2249
- crate :: render_tests:: try_run_tests ( builder, & mut cargo. into ( ) ) ;
2229
+ run_cargo_test ( cargo, & [ ] , & self . crates , compiler, target, builder) ;
2250
2230
}
2251
2231
}
2252
2232
@@ -2569,13 +2549,15 @@ impl Step for Bootstrap {
2569
2549
check_bootstrap. arg ( "bootstrap_test.py" ) . current_dir ( builder. src . join ( "src/bootstrap/" ) ) ;
2570
2550
try_run ( builder, & mut check_bootstrap) ;
2571
2551
2552
+ let host = builder. config . build ;
2553
+ let compiler = builder. compiler ( 0 , host) ;
2572
2554
let mut cmd = Command :: new ( & builder. initial_cargo ) ;
2573
2555
cmd. arg ( "test" )
2574
2556
. current_dir ( builder. src . join ( "src/bootstrap" ) )
2575
2557
. env ( "RUSTFLAGS" , "-Cdebuginfo=2" )
2576
2558
. env ( "CARGO_TARGET_DIR" , builder. out . join ( "bootstrap" ) )
2577
2559
. env ( "RUSTC_BOOTSTRAP" , "1" )
2578
- . env ( "RUSTDOC" , builder. rustdoc ( builder . compiler ( 0 , builder . build . build ) ) )
2560
+ . env ( "RUSTDOC" , builder. rustdoc ( compiler) )
2579
2561
. env ( "RUSTC" , & builder. initial_rustc ) ;
2580
2562
if let Some ( flags) = option_env ! ( "RUSTFLAGS" ) {
2581
2563
// Use the same rustc flags for testing as for "normal" compilation,
@@ -2585,7 +2567,7 @@ impl Step for Bootstrap {
2585
2567
}
2586
2568
// rustbuild tests are racy on directory creation so just run them one at a time.
2587
2569
// Since there's not many this shouldn't be a problem.
2588
- cargo_test_args ( & mut cmd, & [ "--test-threads=1" ] , & [ ] , builder) ;
2570
+ run_cargo_test ( cmd, & [ "--test-threads=1" ] , & [ ] , compiler , host , builder) ;
2589
2571
}
2590
2572
2591
2573
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
0 commit comments