@@ -36,77 +36,19 @@ use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
3636use crate :: { CLang , DocTests , GitRepo , Mode , PathSet , envify} ;
3737
3838mod book_tests;
39+ mod bootstrap_self_tests;
3940mod test_helpers;
4041mod tidy;
4142
4243pub ( crate ) use book_tests:: {
4344 EditionGuide , EmbeddedBook , ErrorIndex , Nomicon , Reference , RustByExample , RustcBook ,
4445 RustdocBook , TheBook , UnstableBook ,
4546} ;
47+ pub ( crate ) use bootstrap_self_tests:: { Bootstrap , CrateBootstrap } ;
4648pub ( crate ) use tidy:: Tidy ;
4749
4850const ADB_TEST_DIR : & str = "/data/local/tmp/work" ;
4951
50- /// Runs `cargo test` on various internal tools used by bootstrap.
51- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
52- pub struct CrateBootstrap {
53- path : PathBuf ,
54- host : TargetSelection ,
55- }
56-
57- impl Step for CrateBootstrap {
58- type Output = ( ) ;
59- const ONLY_HOSTS : bool = true ;
60- const DEFAULT : bool = true ;
61-
62- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
63- // This step is responsible for several different tool paths. By default
64- // it will test all of them, but requesting specific tools on the
65- // command-line (e.g. `./x test suggest-tests`) will test only the
66- // specified tools.
67- run. path ( "src/tools/jsondoclint" )
68- . path ( "src/tools/suggest-tests" )
69- . path ( "src/tools/replace-version-placeholder" )
70- // We want `./x test tidy` to _run_ the tidy tool, not its tests.
71- // So we need a separate alias to test the tidy tool itself.
72- . alias ( "tidyselftest" )
73- }
74-
75- fn make_run ( run : RunConfig < ' _ > ) {
76- // Create and ensure a separate instance of this step for each path
77- // that was selected on the command-line (or selected by default).
78- for path in run. paths {
79- let path = path. assert_single_path ( ) . path . clone ( ) ;
80- run. builder . ensure ( CrateBootstrap { host : run. target , path } ) ;
81- }
82- }
83-
84- fn run ( self , builder : & Builder < ' _ > ) {
85- let bootstrap_host = builder. config . build ;
86- let compiler = builder. compiler ( 0 , bootstrap_host) ;
87- let mut path = self . path . to_str ( ) . unwrap ( ) ;
88-
89- // Map alias `tidyselftest` back to the actual crate path of tidy.
90- if path == "tidyselftest" {
91- path = "src/tools/tidy" ;
92- }
93-
94- let cargo = tool:: prepare_tool_cargo (
95- builder,
96- compiler,
97- Mode :: ToolBootstrap ,
98- bootstrap_host,
99- Kind :: Test ,
100- path,
101- SourceType :: InTree ,
102- & [ ] ,
103- ) ;
104-
105- let crate_name = path. rsplit_once ( '/' ) . unwrap ( ) . 1 ;
106- run_cargo_test ( cargo, & [ ] , & [ ] , crate_name, crate_name, bootstrap_host, builder) ;
107- }
108- }
109-
11052#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
11153pub struct Linkcheck {
11254 host : TargetSelection ,
@@ -2558,67 +2500,6 @@ impl Step for Distcheck {
25582500 }
25592501}
25602502
2561- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2562- pub struct Bootstrap ;
2563-
2564- impl Step for Bootstrap {
2565- type Output = ( ) ;
2566- const DEFAULT : bool = true ;
2567- const ONLY_HOSTS : bool = true ;
2568-
2569- /// Tests the build system itself.
2570- fn run ( self , builder : & Builder < ' _ > ) {
2571- let host = builder. config . build ;
2572- let compiler = builder. compiler ( 0 , host) ;
2573- let _guard = builder. msg ( Kind :: Test , 0 , "bootstrap" , host, host) ;
2574-
2575- // Some tests require cargo submodule to be present.
2576- builder. build . require_submodule ( "src/tools/cargo" , None ) ;
2577-
2578- let mut check_bootstrap = command ( builder. python ( ) ) ;
2579- check_bootstrap
2580- . args ( [ "-m" , "unittest" , "bootstrap_test.py" ] )
2581- . env ( "BUILD_DIR" , & builder. out )
2582- . env ( "BUILD_PLATFORM" , builder. build . build . triple )
2583- . env ( "BOOTSTRAP_TEST_RUSTC_BIN" , & builder. initial_rustc )
2584- . env ( "BOOTSTRAP_TEST_CARGO_BIN" , & builder. initial_cargo )
2585- . current_dir ( builder. src . join ( "src/bootstrap/" ) ) ;
2586- // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
2587- // Use `python -m unittest` manually if you want to pass arguments.
2588- check_bootstrap. delay_failure ( ) . run ( builder) ;
2589-
2590- let mut cargo = tool:: prepare_tool_cargo (
2591- builder,
2592- compiler,
2593- Mode :: ToolBootstrap ,
2594- host,
2595- Kind :: Test ,
2596- "src/bootstrap" ,
2597- SourceType :: InTree ,
2598- & [ ] ,
2599- ) ;
2600-
2601- cargo. release_build ( false ) ;
2602-
2603- cargo
2604- . rustflag ( "-Cdebuginfo=2" )
2605- . env ( "CARGO_TARGET_DIR" , builder. out . join ( "bootstrap" ) )
2606- . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
2607-
2608- // bootstrap tests are racy on directory creation so just run them one at a time.
2609- // Since there's not many this shouldn't be a problem.
2610- run_cargo_test ( cargo, & [ "--test-threads=1" ] , & [ ] , "bootstrap" , None , host, builder) ;
2611- }
2612-
2613- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
2614- run. path ( "src/bootstrap" )
2615- }
2616-
2617- fn make_run ( run : RunConfig < ' _ > ) {
2618- run. builder . ensure ( Bootstrap ) ;
2619- }
2620- }
2621-
26222503#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
26232504pub struct TierCheck {
26242505 pub compiler : Compiler ,
0 commit comments