@@ -23,7 +23,7 @@ use std::path::{PathBuf, Path};
23
23
use std:: process:: Command ;
24
24
use std:: io:: Read ;
25
25
26
- use build_helper:: { self , output} ;
26
+ use build_helper:: { self , output, BuildExpectation } ;
27
27
28
28
use builder:: { Kind , RunConfig , ShouldRun , Builder , Compiler , Step } ;
29
29
use cache:: { INTERNER , Interned } ;
@@ -33,6 +33,7 @@ use native;
33
33
use tool:: { self , Tool } ;
34
34
use util:: { self , dylib_path, dylib_path_var} ;
35
35
use { Build , Mode } ;
36
+ use toolstate:: ToolState ;
36
37
37
38
const ADB_TEST_DIR : & str = "/data/tmp/work" ;
38
39
@@ -64,17 +65,21 @@ impl fmt::Display for TestKind {
64
65
}
65
66
}
66
67
67
- fn try_run ( build : & Build , cmd : & mut Command ) {
68
+ fn try_run_expecting ( build : & Build , cmd : & mut Command , expect : BuildExpectation ) {
68
69
if !build. fail_fast {
69
- if !build. try_run ( cmd) {
70
+ if !build. try_run ( cmd, expect ) {
70
71
let failures = build. delayed_failures . get ( ) ;
71
72
build. delayed_failures . set ( failures + 1 ) ;
72
73
}
73
74
} else {
74
- build. run ( cmd) ;
75
+ build. run_expecting ( cmd, expect ) ;
75
76
}
76
77
}
77
78
79
+ fn try_run ( build : & Build , cmd : & mut Command ) {
80
+ try_run_expecting ( build, cmd, BuildExpectation :: None )
81
+ }
82
+
78
83
fn try_run_quiet ( build : & Build , cmd : & mut Command ) {
79
84
if !build. fail_fast {
80
85
if !build. try_run_quiet ( cmd) {
@@ -294,6 +299,56 @@ impl Step for Rustfmt {
294
299
}
295
300
}
296
301
302
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
303
+ pub struct Miri {
304
+ host : Interned < String > ,
305
+ }
306
+
307
+ impl Step for Miri {
308
+ type Output = ( ) ;
309
+ const ONLY_HOSTS : bool = true ;
310
+ const DEFAULT : bool = true ;
311
+
312
+ fn should_run ( run : ShouldRun ) -> ShouldRun {
313
+ let test_miri = run. builder . build . config . test_miri ;
314
+ run. path ( "src/tools/miri" ) . default_condition ( test_miri)
315
+ }
316
+
317
+ fn make_run ( run : RunConfig ) {
318
+ run. builder . ensure ( Miri {
319
+ host : run. target ,
320
+ } ) ;
321
+ }
322
+
323
+ /// Runs `cargo test` for miri.
324
+ fn run ( self , builder : & Builder ) {
325
+ let build = builder. build ;
326
+ let host = self . host ;
327
+ let compiler = builder. compiler ( 1 , host) ;
328
+
329
+ let miri = builder. ensure ( tool:: Miri { compiler, target : self . host } ) ;
330
+ let mut cargo = builder. cargo ( compiler, Mode :: Tool , host, "test" ) ;
331
+ cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/miri/Cargo.toml" ) ) ;
332
+
333
+ // Don't build tests dynamically, just a pain to work with
334
+ cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
335
+ // miri tests need to know about the stage sysroot
336
+ cargo. env ( "MIRI_SYSROOT" , builder. sysroot ( compiler) ) ;
337
+ cargo. env ( "RUSTC_TEST_SUITE" , builder. rustc ( compiler) ) ;
338
+ cargo. env ( "RUSTC_LIB_PATH" , builder. rustc_libdir ( compiler) ) ;
339
+ cargo. env ( "MIRI_PATH" , miri) ;
340
+
341
+ builder. add_rustc_lib_path ( compiler, & mut cargo) ;
342
+
343
+ try_run_expecting (
344
+ build,
345
+ & mut cargo,
346
+ builder. build . config . toolstate . miri . passes ( ToolState :: Testing ) ,
347
+ ) ;
348
+ }
349
+ }
350
+
351
+
297
352
fn path_for_cargo ( builder : & Builder , compiler : Compiler ) -> OsString {
298
353
// Configure PATH to find the right rustc. NB. we have to use PATH
299
354
// and not RUSTC because the Cargo test suite has tests that will
0 commit comments