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