@@ -8,6 +8,7 @@ use std::ffi::{OsStr, OsString};
8
8
use std:: path:: { Path , PathBuf } ;
9
9
use std:: { env, fs, iter} ;
10
10
11
+ use build_helper:: compiletest:: Mode as CtMode ;
11
12
use clap_complete:: shells;
12
13
13
14
use crate :: core:: build_steps:: compile:: run_cargo;
@@ -915,7 +916,7 @@ impl Step for RustdocJSNotStd {
915
916
builder. ensure ( Compiletest {
916
917
compiler : self . compiler ,
917
918
target : self . target ,
918
- mode : "rustdoc-js" ,
919
+ mode : CtMode :: RustdocJs ,
919
920
suite : "rustdoc-js" ,
920
921
path : "tests/rustdoc-js" ,
921
922
compare_mode : None ,
@@ -1347,68 +1348,68 @@ impl Step for CrateBuildHelper {
1347
1348
}
1348
1349
}
1349
1350
1350
- test ! ( Ui { path: "tests/ui" , mode: "ui" , suite: "ui" , default : true } ) ;
1351
+ test ! ( Ui { path: "tests/ui" , mode: CtMode :: Ui , suite: "ui" , default : true } ) ;
1351
1352
1352
- test ! ( Crashes { path: "tests/crashes" , mode: "crashes" , suite: "crashes" , default : true } ) ;
1353
+ test ! ( Crashes { path: "tests/crashes" , mode: CtMode :: Crashes , suite: "crashes" , default : true } ) ;
1353
1354
1354
- test ! ( Codegen { path: "tests/codegen" , mode: "codegen" , suite: "codegen" , default : true } ) ;
1355
+ test ! ( Codegen { path: "tests/codegen" , mode: CtMode :: Codegen , suite: "codegen" , default : true } ) ;
1355
1356
1356
1357
test ! ( CodegenUnits {
1357
1358
path: "tests/codegen-units" ,
1358
- mode: "codegen-units" ,
1359
+ mode: CtMode :: CodegenUnits ,
1359
1360
suite: "codegen-units" ,
1360
1361
default : true ,
1361
1362
} ) ;
1362
1363
1363
1364
test ! ( Incremental {
1364
1365
path: "tests/incremental" ,
1365
- mode: "incremental" ,
1366
+ mode: CtMode :: Incremental ,
1366
1367
suite: "incremental" ,
1367
1368
default : true ,
1368
1369
} ) ;
1369
1370
1370
1371
test ! ( Debuginfo {
1371
1372
path: "tests/debuginfo" ,
1372
- mode: "debuginfo" ,
1373
+ mode: CtMode :: DebugInfo ,
1373
1374
suite: "debuginfo" ,
1374
1375
default : true ,
1375
1376
compare_mode: Some ( "split-dwarf" ) ,
1376
1377
} ) ;
1377
1378
1378
1379
test ! ( UiFullDeps {
1379
1380
path: "tests/ui-fulldeps" ,
1380
- mode: "ui" ,
1381
+ mode: CtMode :: Ui ,
1381
1382
suite: "ui-fulldeps" ,
1382
1383
default : true ,
1383
1384
only_hosts: true ,
1384
1385
} ) ;
1385
1386
1386
1387
test ! ( Rustdoc {
1387
1388
path: "tests/rustdoc" ,
1388
- mode: "rustdoc" ,
1389
+ mode: CtMode :: Rustdoc ,
1389
1390
suite: "rustdoc" ,
1390
1391
default : true ,
1391
1392
only_hosts: true ,
1392
1393
} ) ;
1393
1394
test ! ( RustdocUi {
1394
1395
path: "tests/rustdoc-ui" ,
1395
- mode: "ui" ,
1396
+ mode: CtMode :: Ui ,
1396
1397
suite: "rustdoc-ui" ,
1397
1398
default : true ,
1398
1399
only_hosts: true ,
1399
1400
} ) ;
1400
1401
1401
1402
test ! ( RustdocJson {
1402
1403
path: "tests/rustdoc-json" ,
1403
- mode: "rustdoc-json" ,
1404
+ mode: CtMode :: RustdocJson ,
1404
1405
suite: "rustdoc-json" ,
1405
1406
default : true ,
1406
1407
only_hosts: true ,
1407
1408
} ) ;
1408
1409
1409
1410
test ! ( Pretty {
1410
1411
path: "tests/pretty" ,
1411
- mode: "pretty" ,
1412
+ mode: CtMode :: Pretty ,
1412
1413
suite: "pretty" ,
1413
1414
default : true ,
1414
1415
only_hosts: true ,
@@ -1441,15 +1442,20 @@ impl Step for RunMake {
1441
1442
builder. ensure ( Compiletest {
1442
1443
compiler : self . compiler ,
1443
1444
target : self . target ,
1444
- mode : "run-make" ,
1445
+ mode : CtMode :: RunMake ,
1445
1446
suite : "run-make" ,
1446
1447
path : "tests/run-make" ,
1447
1448
compare_mode : None ,
1448
1449
} ) ;
1449
1450
}
1450
1451
}
1451
1452
1452
- test ! ( Assembly { path: "tests/assembly" , mode: "assembly" , suite: "assembly" , default : true } ) ;
1453
+ test ! ( Assembly {
1454
+ path: "tests/assembly" ,
1455
+ mode: CtMode :: Assembly ,
1456
+ suite: "assembly" ,
1457
+ default : true
1458
+ } ) ;
1453
1459
1454
1460
/// Runs the coverage test suite at `tests/coverage` in some or all of the
1455
1461
/// coverage test modes.
@@ -1536,7 +1542,7 @@ impl Step for Coverage {
1536
1542
builder. ensure ( Compiletest {
1537
1543
compiler,
1538
1544
target,
1539
- mode,
1545
+ mode : mode . parse ( ) . unwrap ( ) ,
1540
1546
suite : Self :: SUITE ,
1541
1547
path : Self :: PATH ,
1542
1548
compare_mode : None ,
@@ -1546,7 +1552,7 @@ impl Step for Coverage {
1546
1552
1547
1553
test ! ( CoverageRunRustdoc {
1548
1554
path: "tests/coverage-run-rustdoc" ,
1549
- mode: "coverage-run" ,
1555
+ mode: CtMode :: CoverageRun ,
1550
1556
suite: "coverage-run-rustdoc" ,
1551
1557
default : true ,
1552
1558
only_hosts: true ,
@@ -1578,7 +1584,7 @@ impl Step for MirOpt {
1578
1584
builder. ensure ( Compiletest {
1579
1585
compiler : self . compiler ,
1580
1586
target,
1581
- mode : "mir-opt" ,
1587
+ mode : CtMode :: MirOpt ,
1582
1588
suite : "mir-opt" ,
1583
1589
path : "tests/mir-opt" ,
1584
1590
compare_mode : None ,
@@ -1615,7 +1621,7 @@ impl Step for MirOpt {
1615
1621
struct Compiletest {
1616
1622
compiler : Compiler ,
1617
1623
target : TargetSelection ,
1618
- mode : & ' static str ,
1624
+ mode : CtMode ,
1619
1625
suite : & ' static str ,
1620
1626
path : & ' static str ,
1621
1627
compare_mode : Option < & ' static str > ,
@@ -1729,7 +1735,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1729
1735
1730
1736
let is_rustdoc = suite == "rustdoc-ui" || suite == "rustdoc-js" ;
1731
1737
1732
- if mode == "run-make" {
1738
+ if mode == CtMode :: RunMake {
1733
1739
let cargo_path = if builder. top_stage == 0 {
1734
1740
// If we're using `--stage 0`, we should provide the bootstrap cargo.
1735
1741
builder. initial_cargo . clone ( )
@@ -1752,17 +1758,17 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1752
1758
}
1753
1759
1754
1760
// Avoid depending on rustdoc when we don't need it.
1755
- if mode == "rustdoc"
1756
- || mode == "run-make"
1757
- || ( mode == "ui" && is_rustdoc)
1758
- || mode == "rustdoc-js"
1759
- || mode == "rustdoc-json"
1761
+ if mode == CtMode :: Rustdoc
1762
+ || mode == CtMode :: RunMake
1763
+ || ( mode == CtMode :: Ui && is_rustdoc)
1764
+ || mode == CtMode :: RustdocJs
1765
+ || mode == CtMode :: RustdocJson
1760
1766
|| suite == "coverage-run-rustdoc"
1761
1767
{
1762
1768
cmd. arg ( "--rustdoc-path" ) . arg ( builder. rustdoc ( compiler) ) ;
1763
1769
}
1764
1770
1765
- if mode == "rustdoc-json" {
1771
+ if mode == CtMode :: RustdocJson {
1766
1772
// Use the beta compiler for jsondocck
1767
1773
let json_compiler = compiler. with_stage ( 0 ) ;
1768
1774
cmd. arg ( "--jsondocck-path" )
@@ -1771,7 +1777,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1771
1777
. arg ( builder. ensure ( tool:: JsonDocLint { compiler : json_compiler, target } ) ) ;
1772
1778
}
1773
1779
1774
- if matches ! ( mode, "coverage-map" | "coverage-run" ) {
1780
+ if matches ! ( mode, CtMode :: CoverageMap | CtMode :: CoverageRun ) {
1775
1781
let coverage_dump = builder. tool_exe ( Tool :: CoverageDump ) ;
1776
1782
cmd. arg ( "--coverage-dump-path" ) . arg ( coverage_dump) ;
1777
1783
}
@@ -1789,7 +1795,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1789
1795
cmd. arg ( "--sysroot-base" ) . arg ( sysroot) ;
1790
1796
cmd. arg ( "--stage-id" ) . arg ( stage_id) ;
1791
1797
cmd. arg ( "--suite" ) . arg ( suite) ;
1792
- cmd. arg ( "--mode" ) . arg ( mode) ;
1798
+ cmd. arg ( "--mode" ) . arg ( mode. to_str ( ) ) ;
1793
1799
cmd. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
1794
1800
cmd. arg ( "--host" ) . arg ( & * compiler. host . triple ) ;
1795
1801
cmd. arg ( "--llvm-filecheck" ) . arg ( builder. llvm_filecheck ( builder. config . build ) ) ;
@@ -1827,7 +1833,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1827
1833
1828
1834
if let Some ( ref nodejs) = builder. config . nodejs {
1829
1835
cmd. arg ( "--nodejs" ) . arg ( nodejs) ;
1830
- } else if mode == "rustdoc-js" {
1836
+ } else if mode == CtMode :: RustdocJs {
1831
1837
panic ! ( "need nodejs to run rustdoc-js suite" ) ;
1832
1838
}
1833
1839
if let Some ( ref npm) = builder. config . npm {
@@ -1985,7 +1991,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1985
1991
cmd. env ( "RUSTFLAGS" , rustflags) ;
1986
1992
}
1987
1993
1988
- if !builder. config . dry_run ( ) && matches ! ( mode, "run-make" | "coverage-run" ) {
1994
+ if !builder. config . dry_run ( ) && matches ! ( mode, CtMode :: RunMake | CtMode :: CoverageRun ) {
1989
1995
// The llvm/bin directory contains many useful cross-platform
1990
1996
// tools. Pass the path to run-make tests so they can use them.
1991
1997
// (The coverage-run tests also need these tools to process
@@ -1997,7 +2003,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
1997
2003
cmd. arg ( "--llvm-bin-dir" ) . arg ( llvm_bin_path) ;
1998
2004
}
1999
2005
2000
- if !builder. config . dry_run ( ) && mode == "run-make" {
2006
+ if !builder. config . dry_run ( ) && mode == CtMode :: RunMake {
2001
2007
// If LLD is available, add it to the PATH
2002
2008
if builder. config . lld_enabled {
2003
2009
let lld_install_root =
@@ -2017,7 +2023,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
2017
2023
2018
2024
// Only pass correct values for these flags for the `run-make` suite as it
2019
2025
// requires that a C++ compiler was configured which isn't always the case.
2020
- if !builder. config . dry_run ( ) && mode == "run-make" {
2026
+ if !builder. config . dry_run ( ) && mode == CtMode :: RunMake {
2021
2027
cmd. arg ( "--cc" )
2022
2028
. arg ( builder. cc ( target) )
2023
2029
. arg ( "--cxx" )
0 commit comments