@@ -7,6 +7,7 @@ mod build_sysroot;
77mod config;
88mod prepare;
99mod rustc_info;
10+ mod tests;
1011mod utils;
1112
1213fn usage ( ) {
@@ -15,6 +16,9 @@ fn usage() {
1516 eprintln ! (
1617 " ./y.rs build [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]"
1718 ) ;
19+ eprintln ! (
20+ " ./y.rs test [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--no-unstable-features]"
21+ ) ;
1822}
1923
2024macro_rules! arg_error {
@@ -25,11 +29,13 @@ macro_rules! arg_error {
2529 } } ;
2630}
2731
32+ #[ derive( PartialEq , Debug ) ]
2833enum Command {
2934 Build ,
35+ Test ,
3036}
3137
32- #[ derive( Copy , Clone ) ]
38+ #[ derive( Copy , Clone , Debug ) ]
3339pub ( crate ) enum SysrootKind {
3440 None ,
3541 Clif ,
@@ -46,12 +52,13 @@ pub fn main() {
4652 let command = match args. next ( ) . as_deref ( ) {
4753 Some ( "prepare" ) => {
4854 if args. next ( ) . is_some ( ) {
49- arg_error ! ( "./x .rs prepare doesn't expect arguments" ) ;
55+ arg_error ! ( "./y .rs prepare doesn't expect arguments" ) ;
5056 }
5157 prepare:: prepare ( ) ;
5258 process:: exit ( 0 ) ;
5359 }
5460 Some ( "build" ) => Command :: Build ,
61+ Some ( "test" ) => Command :: Test ,
5562 Some ( flag) if flag. starts_with ( '-' ) => arg_error ! ( "Expected command found flag {}" , flag) ,
5663 Some ( command) => arg_error ! ( "Unknown command {}" , command) ,
5764 None => {
@@ -117,12 +124,26 @@ pub fn main() {
117124
118125 let cg_clif_build_dir =
119126 build_backend:: build_backend ( channel, & host_triple, use_unstable_features) ;
120- build_sysroot:: build_sysroot (
121- channel,
122- sysroot_kind,
123- & target_dir,
124- cg_clif_build_dir,
125- & host_triple,
126- & target_triple,
127- ) ;
127+ match command {
128+ Command :: Test => {
129+ tests:: run_tests (
130+ channel,
131+ sysroot_kind,
132+ & target_dir,
133+ & cg_clif_build_dir,
134+ & host_triple,
135+ & target_triple,
136+ ) ;
137+ }
138+ Command :: Build => {
139+ build_sysroot:: build_sysroot (
140+ channel,
141+ sysroot_kind,
142+ & target_dir,
143+ & cg_clif_build_dir,
144+ & host_triple,
145+ & target_triple,
146+ ) ;
147+ }
148+ }
128149}
0 commit comments