5
5
6
6
use std:: env;
7
7
use std:: ffi:: OsString ;
8
- use std:: fmt;
9
8
use std:: fs;
10
9
use std:: iter;
11
10
use std:: path:: { Path , PathBuf } ;
@@ -28,44 +27,6 @@ use crate::{envify, CLang, DocTests, GitRepo, Mode};
28
27
29
28
const ADB_TEST_DIR : & str = "/data/local/tmp/work" ;
30
29
31
- /// The two modes of the test runner; tests or benchmarks.
32
- #[ derive( Debug , PartialEq , Eq , Hash , Copy , Clone , PartialOrd , Ord ) ]
33
- pub enum TestKind {
34
- /// Run `cargo test`.
35
- Test ,
36
- /// Run `cargo bench`.
37
- Bench ,
38
- }
39
-
40
- impl From < Kind > for TestKind {
41
- fn from ( kind : Kind ) -> Self {
42
- match kind {
43
- Kind :: Test => TestKind :: Test ,
44
- Kind :: Bench => TestKind :: Bench ,
45
- _ => panic ! ( "unexpected kind in crate: {:?}" , kind) ,
46
- }
47
- }
48
- }
49
-
50
- impl TestKind {
51
- // Return the cargo subcommand for this test kind
52
- fn subcommand ( self ) -> & ' static str {
53
- match self {
54
- TestKind :: Test => "test" ,
55
- TestKind :: Bench => "bench" ,
56
- }
57
- }
58
- }
59
-
60
- impl fmt:: Display for TestKind {
61
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
62
- f. write_str ( match * self {
63
- TestKind :: Test => "Testing" ,
64
- TestKind :: Bench => "Benchmarking" ,
65
- } )
66
- }
67
- }
68
-
69
30
fn try_run ( builder : & Builder < ' _ > , cmd : & mut Command ) -> bool {
70
31
if !builder. fail_fast {
71
32
if !builder. try_run ( cmd) {
@@ -2105,7 +2066,6 @@ impl Step for RustcGuide {
2105
2066
pub struct CrateLibrustc {
2106
2067
compiler : Compiler ,
2107
2068
target : TargetSelection ,
2108
- test_kind : TestKind ,
2109
2069
crates : Vec < Interned < String > > ,
2110
2070
}
2111
2071
@@ -2127,17 +2087,15 @@ impl Step for CrateLibrustc {
2127
2087
. iter ( )
2128
2088
. map ( |p| builder. crate_paths [ & p. assert_single_path ( ) . path ] . clone ( ) )
2129
2089
. collect ( ) ;
2130
- let test_kind = builder. kind . into ( ) ;
2131
2090
2132
- builder. ensure ( CrateLibrustc { compiler, target : run. target , test_kind , crates } ) ;
2091
+ builder. ensure ( CrateLibrustc { compiler, target : run. target , crates } ) ;
2133
2092
}
2134
2093
2135
2094
fn run ( self , builder : & Builder < ' _ > ) {
2136
2095
builder. ensure ( Crate {
2137
2096
compiler : self . compiler ,
2138
2097
target : self . target ,
2139
2098
mode : Mode :: Rustc ,
2140
- test_kind : self . test_kind ,
2141
2099
crates : self . crates ,
2142
2100
} ) ;
2143
2101
}
@@ -2148,7 +2106,6 @@ pub struct Crate {
2148
2106
pub compiler : Compiler ,
2149
2107
pub target : TargetSelection ,
2150
2108
pub mode : Mode ,
2151
- pub test_kind : TestKind ,
2152
2109
pub crates : Vec < Interned < String > > ,
2153
2110
}
2154
2111
@@ -2164,14 +2121,13 @@ impl Step for Crate {
2164
2121
let builder = run. builder ;
2165
2122
let host = run. build_triple ( ) ;
2166
2123
let compiler = builder. compiler_for ( builder. top_stage , host, host) ;
2167
- let test_kind = builder. kind . into ( ) ;
2168
2124
let crates = run
2169
2125
. paths
2170
2126
. iter ( )
2171
2127
. map ( |p| builder. crate_paths [ & p. assert_single_path ( ) . path ] . clone ( ) )
2172
2128
. collect ( ) ;
2173
2129
2174
- builder. ensure ( Crate { compiler, target : run. target , mode : Mode :: Std , test_kind , crates } ) ;
2130
+ builder. ensure ( Crate { compiler, target : run. target , mode : Mode :: Std , crates } ) ;
2175
2131
}
2176
2132
2177
2133
/// Runs all unit tests plus documentation tests for a given crate defined
@@ -2186,7 +2142,6 @@ impl Step for Crate {
2186
2142
let compiler = self . compiler ;
2187
2143
let target = self . target ;
2188
2144
let mode = self . mode ;
2189
- let test_kind = self . test_kind ;
2190
2145
2191
2146
builder. ensure ( compile:: Std :: new ( compiler, target) ) ;
2192
2147
builder. ensure ( RemoteCopyLibs { compiler, target } ) ;
@@ -2198,7 +2153,7 @@ impl Step for Crate {
2198
2153
let compiler = builder. compiler_for ( compiler. stage , compiler. host , target) ;
2199
2154
2200
2155
let mut cargo =
2201
- builder. cargo ( compiler, mode, SourceType :: InTree , target, test_kind . subcommand ( ) ) ;
2156
+ builder. cargo ( compiler, mode, SourceType :: InTree , target, builder . kind . as_str ( ) ) ;
2202
2157
match mode {
2203
2158
Mode :: Std => {
2204
2159
compile:: std_cargo ( builder, target, compiler. stage , & mut cargo) ;
@@ -2214,7 +2169,7 @@ impl Step for Crate {
2214
2169
// Pass in some standard flags then iterate over the graph we've discovered
2215
2170
// in `cargo metadata` with the maps above and figure out what `-p`
2216
2171
// arguments need to get passed.
2217
- if test_kind . subcommand ( ) == "test" && !builder. fail_fast {
2172
+ if builder . kind == Kind :: Test && !builder. fail_fast {
2218
2173
cargo. arg ( "--no-fail-fast" ) ;
2219
2174
}
2220
2175
match builder. doc_tests {
@@ -2265,7 +2220,7 @@ impl Step for Crate {
2265
2220
2266
2221
builder. info ( & format ! (
2267
2222
"{}{} stage{} ({} -> {})" ,
2268
- test_kind ,
2223
+ builder . kind . test_description ( ) ,
2269
2224
crate_description( & self . crates) ,
2270
2225
compiler. stage,
2271
2226
& compiler. host,
@@ -2280,7 +2235,6 @@ impl Step for Crate {
2280
2235
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
2281
2236
pub struct CrateRustdoc {
2282
2237
host : TargetSelection ,
2283
- test_kind : TestKind ,
2284
2238
}
2285
2239
2286
2240
impl Step for CrateRustdoc {
@@ -2295,13 +2249,10 @@ impl Step for CrateRustdoc {
2295
2249
fn make_run ( run : RunConfig < ' _ > ) {
2296
2250
let builder = run. builder ;
2297
2251
2298
- let test_kind = builder. kind . into ( ) ;
2299
-
2300
- builder. ensure ( CrateRustdoc { host : run. target , test_kind } ) ;
2252
+ builder. ensure ( CrateRustdoc { host : run. target } ) ;
2301
2253
}
2302
2254
2303
2255
fn run ( self , builder : & Builder < ' _ > ) {
2304
- let test_kind = self . test_kind ;
2305
2256
let target = self . host ;
2306
2257
2307
2258
let compiler = if builder. download_rustc ( ) {
@@ -2320,12 +2271,12 @@ impl Step for CrateRustdoc {
2320
2271
compiler,
2321
2272
Mode :: ToolRustc ,
2322
2273
target,
2323
- test_kind . subcommand ( ) ,
2274
+ builder . kind . as_str ( ) ,
2324
2275
"src/tools/rustdoc" ,
2325
2276
SourceType :: InTree ,
2326
2277
& [ ] ,
2327
2278
) ;
2328
- if test_kind . subcommand ( ) == "test" && !builder. fail_fast {
2279
+ if builder . kind == Kind :: Test && !builder. fail_fast {
2329
2280
cargo. arg ( "--no-fail-fast" ) ;
2330
2281
}
2331
2282
match builder. doc_tests {
@@ -2388,7 +2339,10 @@ impl Step for CrateRustdoc {
2388
2339
2389
2340
builder. info ( & format ! (
2390
2341
"{} rustdoc stage{} ({} -> {})" ,
2391
- test_kind, compiler. stage, & compiler. host, target
2342
+ builder. kind. test_description( ) ,
2343
+ compiler. stage,
2344
+ & compiler. host,
2345
+ target
2392
2346
) ) ;
2393
2347
let _time = util:: timeit ( & builder) ;
2394
2348
@@ -2399,7 +2353,6 @@ impl Step for CrateRustdoc {
2399
2353
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
2400
2354
pub struct CrateRustdocJsonTypes {
2401
2355
host : TargetSelection ,
2402
- test_kind : TestKind ,
2403
2356
}
2404
2357
2405
2358
impl Step for CrateRustdocJsonTypes {
@@ -2414,13 +2367,10 @@ impl Step for CrateRustdocJsonTypes {
2414
2367
fn make_run ( run : RunConfig < ' _ > ) {
2415
2368
let builder = run. builder ;
2416
2369
2417
- let test_kind = builder. kind . into ( ) ;
2418
-
2419
- builder. ensure ( CrateRustdocJsonTypes { host : run. target , test_kind } ) ;
2370
+ builder. ensure ( CrateRustdocJsonTypes { host : run. target } ) ;
2420
2371
}
2421
2372
2422
2373
fn run ( self , builder : & Builder < ' _ > ) {
2423
- let test_kind = self . test_kind ;
2424
2374
let target = self . host ;
2425
2375
2426
2376
// Use the previous stage compiler to reuse the artifacts that are
@@ -2435,12 +2385,12 @@ impl Step for CrateRustdocJsonTypes {
2435
2385
compiler,
2436
2386
Mode :: ToolRustc ,
2437
2387
target,
2438
- test_kind . subcommand ( ) ,
2388
+ builder . kind . as_str ( ) ,
2439
2389
"src/rustdoc-json-types" ,
2440
2390
SourceType :: InTree ,
2441
2391
& [ ] ,
2442
2392
) ;
2443
- if test_kind . subcommand ( ) == "test" && !builder. fail_fast {
2393
+ if builder . kind == Kind :: Test && !builder. fail_fast {
2444
2394
cargo. arg ( "--no-fail-fast" ) ;
2445
2395
}
2446
2396
@@ -2455,7 +2405,10 @@ impl Step for CrateRustdocJsonTypes {
2455
2405
2456
2406
builder. info ( & format ! (
2457
2407
"{} rustdoc-json-types stage{} ({} -> {})" ,
2458
- test_kind, compiler. stage, & compiler. host, target
2408
+ builder. kind. test_description( ) ,
2409
+ compiler. stage,
2410
+ & compiler. host,
2411
+ target
2459
2412
) ) ;
2460
2413
let _time = util:: timeit ( & builder) ;
2461
2414
0 commit comments