1
1
use super :: build_sysroot;
2
2
use super :: config;
3
3
use super :: rustc_info:: get_wrapper_file_name;
4
- use super :: utils:: { spawn_and_wait, spawn_and_wait_with_input} ;
4
+ use super :: utils:: { cargo_command , spawn_and_wait, spawn_and_wait_with_input} ;
5
5
use build_system:: SysrootKind ;
6
6
use std:: env;
7
7
use std:: ffi:: OsStr ;
@@ -218,20 +218,14 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
218
218
const EXTENDED_SYSROOT_SUITE : & [ TestCase ] = & [
219
219
TestCase :: new ( "test.rust-random/rand" , & |runner| {
220
220
runner. in_dir ( [ "rand" ] , |runner| {
221
- runner. run_cargo ( [ "clean" ] ) ;
221
+ runner. run_cargo ( "clean" , [ ] ) ;
222
222
223
223
if runner. host_triple == runner. target_triple {
224
224
eprintln ! ( "[TEST] rust-random/rand" ) ;
225
- runner. run_cargo ( [ "test" , "--workspace" ] ) ;
225
+ runner. run_cargo ( "test" , [ "--workspace" ] ) ;
226
226
} else {
227
227
eprintln ! ( "[AOT] rust-random/rand" ) ;
228
- runner. run_cargo ( [
229
- "build" ,
230
- "--workspace" ,
231
- "--target" ,
232
- & runner. target_triple ,
233
- "--tests" ,
234
- ] ) ;
228
+ runner. run_cargo ( "build" , [ "--workspace" , "--tests" ] ) ;
235
229
}
236
230
} ) ;
237
231
} ) ,
@@ -247,11 +241,19 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
247
241
bench_compile. arg ( "--warmup" ) ;
248
242
bench_compile. arg ( "1" ) ;
249
243
bench_compile. arg ( "--prepare" ) ;
250
- bench_compile. arg ( format ! ( "{:?}" , runner. cargo_command( [ "clean" ] ) ) ) ;
244
+ bench_compile. arg ( format ! ( "{:?}" , runner. cargo_command( "clean" , [ ] ) ) ) ;
251
245
252
246
bench_compile. arg ( "cargo build" ) ;
253
247
254
- bench_compile. arg ( format ! ( "{:?}" , runner. cargo_command( [ "build" ] ) ) ) ;
248
+ let cargo_clif = runner
249
+ . root_dir
250
+ . clone ( )
251
+ . join ( "build" )
252
+ . join ( get_wrapper_file_name ( "cargo-clif" , "bin" ) ) ;
253
+ let mut clif_build_cmd = cargo_command ( cargo_clif, "build" , None , Path :: new ( "." ) ) ;
254
+ clif_build_cmd. env ( "RUSTFLAGS" , & runner. rust_flags ) ;
255
+ bench_compile. arg ( format ! ( "{:?}" , clif_build_cmd) ) ;
256
+
255
257
spawn_and_wait ( bench_compile) ;
256
258
257
259
eprintln ! ( "[BENCH RUN] ebobby/simple-raytracer" ) ;
@@ -265,51 +267,39 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
265
267
bench_run. arg ( PathBuf :: from ( "./raytracer_cg_clif" ) ) ;
266
268
spawn_and_wait ( bench_run) ;
267
269
} else {
268
- runner. run_cargo ( [ "clean" ] ) ;
270
+ runner. run_cargo ( "clean" , [ ] ) ;
269
271
eprintln ! ( "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" ) ;
270
272
eprintln ! ( "[COMPILE] ebobby/simple-raytracer" ) ;
271
- runner. run_cargo ( [ "build" , "--target" , & runner . target_triple ] ) ;
273
+ runner. run_cargo ( "build" , [ ] ) ;
272
274
eprintln ! ( "[BENCH RUN] ebobby/simple-raytracer (skipped)" ) ;
273
275
}
274
276
} ) ;
275
277
} ) ,
276
278
TestCase :: new ( "test.libcore" , & |runner| {
277
279
runner. in_dir ( [ "build_sysroot" , "sysroot_src" , "library" , "core" , "tests" ] , |runner| {
278
- runner. run_cargo ( [ "clean" ] ) ;
280
+ runner. run_cargo ( "clean" , [ ] ) ;
279
281
280
282
if runner. host_triple == runner. target_triple {
281
- runner. run_cargo ( [ "test" ] ) ;
283
+ runner. run_cargo ( "test" , [ ] ) ;
282
284
} else {
283
285
eprintln ! ( "Cross-Compiling: Not running tests" ) ;
284
- runner. run_cargo ( [ "build" , "--target" , & runner . target_triple , "--tests" ] ) ;
286
+ runner. run_cargo ( "build" , [ "--tests" ] ) ;
285
287
}
286
288
} ) ;
287
289
} ) ,
288
290
TestCase :: new ( "test.regex-shootout-regex-dna" , & |runner| {
289
291
runner. in_dir ( [ "regex" ] , |runner| {
290
- runner. run_cargo ( [ "clean" ] ) ;
292
+ runner. run_cargo ( "clean" , [ ] ) ;
291
293
292
294
// newer aho_corasick versions throw a deprecation warning
293
295
let lint_rust_flags = format ! ( "{} --cap-lints warn" , runner. rust_flags) ;
294
296
295
- let mut build_cmd = runner. cargo_command ( [
296
- "build" ,
297
- "--example" ,
298
- "shootout-regex-dna" ,
299
- "--target" ,
300
- & runner. target_triple ,
301
- ] ) ;
297
+ let mut build_cmd = runner. cargo_command ( "build" , [ "--example" , "shootout-regex-dna" ] ) ;
302
298
build_cmd. env ( "RUSTFLAGS" , lint_rust_flags. clone ( ) ) ;
303
299
spawn_and_wait ( build_cmd) ;
304
300
305
301
if runner. host_triple == runner. target_triple {
306
- let mut run_cmd = runner. cargo_command ( [
307
- "run" ,
308
- "--example" ,
309
- "shootout-regex-dna" ,
310
- "--target" ,
311
- & runner. target_triple ,
312
- ] ) ;
302
+ let mut run_cmd = runner. cargo_command ( "run" , [ "--example" , "shootout-regex-dna" ] ) ;
313
303
run_cmd. env ( "RUSTFLAGS" , lint_rust_flags) ;
314
304
315
305
let input =
@@ -350,40 +340,42 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
350
340
} ) ,
351
341
TestCase :: new ( "test.regex" , & |runner| {
352
342
runner. in_dir ( [ "regex" ] , |runner| {
353
- runner. run_cargo ( [ "clean" ] ) ;
343
+ runner. run_cargo ( "clean" , [ ] ) ;
354
344
355
345
// newer aho_corasick versions throw a deprecation warning
356
346
let lint_rust_flags = format ! ( "{} --cap-lints warn" , runner. rust_flags) ;
357
347
358
348
if runner. host_triple == runner. target_triple {
359
- let mut run_cmd = runner. cargo_command ( [
349
+ let mut run_cmd = runner. cargo_command (
360
350
"test" ,
361
- "--tests" ,
362
- "--" ,
363
- "--exclude-should-panic" ,
364
- "--test-threads" ,
365
- "1" ,
366
- "-Zunstable-options" ,
367
- "-q" ,
368
- ] ) ;
351
+ [
352
+ "--tests" ,
353
+ "--" ,
354
+ "--exclude-should-panic" ,
355
+ "--test-threads" ,
356
+ "1" ,
357
+ "-Zunstable-options" ,
358
+ "-q" ,
359
+ ] ,
360
+ ) ;
369
361
run_cmd. env ( "RUSTFLAGS" , lint_rust_flags) ;
370
362
spawn_and_wait ( run_cmd) ;
371
363
} else {
372
364
eprintln ! ( "Cross-Compiling: Not running tests" ) ;
373
365
let mut build_cmd =
374
- runner. cargo_command ( [ "build" , "--tests" , "--target" , & runner. target_triple ] ) ;
366
+ runner. cargo_command ( "build" , [ "--tests" , "--target" , & runner. target_triple ] ) ;
375
367
build_cmd. env ( "RUSTFLAGS" , lint_rust_flags. clone ( ) ) ;
376
368
spawn_and_wait ( build_cmd) ;
377
369
}
378
370
} ) ;
379
371
} ) ,
380
372
TestCase :: new ( "test.portable-simd" , & |runner| {
381
373
runner. in_dir ( [ "portable-simd" ] , |runner| {
382
- runner. run_cargo ( [ "clean" ] ) ;
383
- runner. run_cargo ( [ "build" , "--all-targets" , "--target" , & runner. target_triple ] ) ;
374
+ runner. run_cargo ( "clean" , [ ] ) ;
375
+ runner. run_cargo ( "build" , [ "--all-targets" , "--target" , & runner. target_triple ] ) ;
384
376
385
377
if runner. host_triple == runner. target_triple {
386
- runner. run_cargo ( [ "test" , "-q" ] ) ;
378
+ runner. run_cargo ( "test" , [ "-q" ] ) ;
387
379
}
388
380
} ) ;
389
381
} ) ,
@@ -590,25 +582,29 @@ impl TestRunner {
590
582
spawn_and_wait ( cmd) ;
591
583
}
592
584
593
- fn cargo_command < I , S > ( & self , args : I ) -> Command
585
+ fn cargo_command < ' a , I > ( & self , subcommand : & str , args : I ) -> Command
594
586
where
595
- I : IntoIterator < Item = S > ,
596
- S : AsRef < OsStr > ,
587
+ I : IntoIterator < Item = & ' a str > ,
597
588
{
598
589
let mut cargo_clif = self . root_dir . clone ( ) ;
599
590
cargo_clif. push ( "build" ) ;
600
591
cargo_clif. push ( get_wrapper_file_name ( "cargo-clif" , "bin" ) ) ;
601
592
602
- let mut cmd = Command :: new ( cargo_clif) ;
593
+ let mut cmd = cargo_command (
594
+ cargo_clif,
595
+ subcommand,
596
+ if subcommand == "clean" { None } else { Some ( & self . target_triple ) } ,
597
+ Path :: new ( "." ) ,
598
+ ) ;
603
599
cmd. args ( args) ;
604
600
cmd. env ( "RUSTFLAGS" , & self . rust_flags ) ;
605
601
cmd
606
602
}
607
603
608
- fn run_cargo < ' a , I > ( & self , args : I )
604
+ fn run_cargo < ' a , I > ( & self , subcommand : & str , args : I )
609
605
where
610
606
I : IntoIterator < Item = & ' a str > ,
611
607
{
612
- spawn_and_wait ( self . cargo_command ( args) ) ;
608
+ spawn_and_wait ( self . cargo_command ( subcommand , args) ) ;
613
609
}
614
610
}
0 commit comments