@@ -16,11 +16,10 @@ use regex::{Captures, Regex};
16
16
use tracing:: * ;
17
17
18
18
use crate :: common:: {
19
- Assembly , Codegen , CodegenUnits , CompareMode , Config , CoverageMap , CoverageRun , Crashes ,
20
- DebugInfo , Debugger , FailMode , Incremental , MirOpt , PassMode , Pretty , RunMake , Rustdoc ,
21
- RustdocJs , RustdocJson , TestPaths , UI_EXTENSIONS , UI_FIXED , UI_RUN_STDERR , UI_RUN_STDOUT ,
22
- UI_STDERR , UI_STDOUT , UI_SVG , UI_WINDOWS_SVG , Ui , expected_output_path, incremental_dir,
23
- output_base_dir, output_base_name, output_testname_unique,
19
+ CompareMode , Config , Debugger , FailMode , PassMode , TestMode , TestPaths , UI_EXTENSIONS ,
20
+ UI_FIXED , UI_RUN_STDERR , UI_RUN_STDOUT , UI_STDERR , UI_STDOUT , UI_SVG , UI_WINDOWS_SVG ,
21
+ expected_output_path, incremental_dir, output_base_dir, output_base_name,
22
+ output_testname_unique,
24
23
} ;
25
24
use crate :: compute_diff:: { DiffLine , make_diff, write_diff, write_filtered_diff} ;
26
25
use crate :: directives:: TestProps ;
@@ -154,7 +153,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
154
153
cx. init_incremental_test ( ) ;
155
154
}
156
155
157
- if config. mode == Incremental {
156
+ if config. mode == TestMode :: Incremental {
158
157
// Incremental tests are special because they cannot be run in
159
158
// parallel.
160
159
assert ! ( !props. revisions. is_empty( ) , "Incremental tests require revisions." ) ;
@@ -203,7 +202,7 @@ pub fn compute_stamp_hash(config: &Config) -> String {
203
202
None => { }
204
203
}
205
204
206
- if let Ui = config. mode {
205
+ if config. mode == TestMode :: Ui {
207
206
config. force_pass_mode . hash ( & mut hash) ;
208
207
}
209
208
@@ -251,25 +250,28 @@ impl<'test> TestCx<'test> {
251
250
/// Code executed for each revision in turn (or, if there are no
252
251
/// revisions, exactly once, with revision == None).
253
252
fn run_revision ( & self ) {
254
- if self . props . should_ice && self . config . mode != Incremental && self . config . mode != Crashes {
253
+ if self . props . should_ice
254
+ && self . config . mode != TestMode :: Incremental
255
+ && self . config . mode != TestMode :: Crashes
256
+ {
255
257
self . fatal ( "cannot use should-ice in a test that is not cfail" ) ;
256
258
}
257
259
match self . config . mode {
258
- Pretty => self . run_pretty_test ( ) ,
259
- DebugInfo => self . run_debuginfo_test ( ) ,
260
- Codegen => self . run_codegen_test ( ) ,
261
- Rustdoc => self . run_rustdoc_test ( ) ,
262
- RustdocJson => self . run_rustdoc_json_test ( ) ,
263
- CodegenUnits => self . run_codegen_units_test ( ) ,
264
- Incremental => self . run_incremental_test ( ) ,
265
- RunMake => self . run_rmake_test ( ) ,
266
- Ui => self . run_ui_test ( ) ,
267
- MirOpt => self . run_mir_opt_test ( ) ,
268
- Assembly => self . run_assembly_test ( ) ,
269
- RustdocJs => self . run_rustdoc_js_test ( ) ,
270
- CoverageMap => self . run_coverage_map_test ( ) , // see self::coverage
271
- CoverageRun => self . run_coverage_run_test ( ) , // see self::coverage
272
- Crashes => self . run_crash_test ( ) ,
260
+ TestMode :: Pretty => self . run_pretty_test ( ) ,
261
+ TestMode :: DebugInfo => self . run_debuginfo_test ( ) ,
262
+ TestMode :: Codegen => self . run_codegen_test ( ) ,
263
+ TestMode :: Rustdoc => self . run_rustdoc_test ( ) ,
264
+ TestMode :: RustdocJson => self . run_rustdoc_json_test ( ) ,
265
+ TestMode :: CodegenUnits => self . run_codegen_units_test ( ) ,
266
+ TestMode :: Incremental => self . run_incremental_test ( ) ,
267
+ TestMode :: RunMake => self . run_rmake_test ( ) ,
268
+ TestMode :: Ui => self . run_ui_test ( ) ,
269
+ TestMode :: MirOpt => self . run_mir_opt_test ( ) ,
270
+ TestMode :: Assembly => self . run_assembly_test ( ) ,
271
+ TestMode :: RustdocJs => self . run_rustdoc_js_test ( ) ,
272
+ TestMode :: CoverageMap => self . run_coverage_map_test ( ) , // see self::coverage
273
+ TestMode :: CoverageRun => self . run_coverage_run_test ( ) , // see self::coverage
274
+ TestMode :: Crashes => self . run_crash_test ( ) ,
273
275
}
274
276
}
275
277
@@ -279,9 +281,13 @@ impl<'test> TestCx<'test> {
279
281
280
282
fn should_run ( & self , pm : Option < PassMode > ) -> WillExecute {
281
283
let test_should_run = match self . config . mode {
282
- Ui if pm == Some ( PassMode :: Run ) || self . props . fail_mode == Some ( FailMode :: Run ) => true ,
283
- MirOpt if pm == Some ( PassMode :: Run ) => true ,
284
- Ui | MirOpt => false ,
284
+ TestMode :: Ui
285
+ if pm == Some ( PassMode :: Run ) || self . props . fail_mode == Some ( FailMode :: Run ) =>
286
+ {
287
+ true
288
+ }
289
+ TestMode :: MirOpt if pm == Some ( PassMode :: Run ) => true ,
290
+ TestMode :: Ui | TestMode :: MirOpt => false ,
285
291
mode => panic ! ( "unimplemented for mode {:?}" , mode) ,
286
292
} ;
287
293
if test_should_run { self . run_if_enabled ( ) } else { WillExecute :: No }
@@ -293,17 +299,17 @@ impl<'test> TestCx<'test> {
293
299
294
300
fn should_run_successfully ( & self , pm : Option < PassMode > ) -> bool {
295
301
match self . config . mode {
296
- Ui | MirOpt => pm == Some ( PassMode :: Run ) ,
302
+ TestMode :: Ui | TestMode :: MirOpt => pm == Some ( PassMode :: Run ) ,
297
303
mode => panic ! ( "unimplemented for mode {:?}" , mode) ,
298
304
}
299
305
}
300
306
301
307
fn should_compile_successfully ( & self , pm : Option < PassMode > ) -> bool {
302
308
match self . config . mode {
303
- RustdocJs => true ,
304
- Ui => pm. is_some ( ) || self . props . fail_mode > Some ( FailMode :: Build ) ,
305
- Crashes => false ,
306
- Incremental => {
309
+ TestMode :: RustdocJs => true ,
310
+ TestMode :: Ui => pm. is_some ( ) || self . props . fail_mode > Some ( FailMode :: Build ) ,
311
+ TestMode :: Crashes => false ,
312
+ TestMode :: Incremental => {
307
313
let revision =
308
314
self . revision . expect ( "incremental tests require a list of revisions" ) ;
309
315
if revision. starts_with ( "cpass" )
@@ -892,7 +898,9 @@ impl<'test> TestCx<'test> {
892
898
893
899
fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> Emit {
894
900
match ( pm, self . props . fail_mode , self . config . mode ) {
895
- ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , Ui ) => Emit :: Metadata ,
901
+ ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , TestMode :: Ui ) => {
902
+ Emit :: Metadata
903
+ }
896
904
_ => Emit :: None ,
897
905
}
898
906
}
@@ -926,7 +934,7 @@ impl<'test> TestCx<'test> {
926
934
} ;
927
935
928
936
let allow_unused = match self . config . mode {
929
- Ui => {
937
+ TestMode :: Ui => {
930
938
// UI tests tend to have tons of unused code as
931
939
// it's just testing various pieces of the compile, but we don't
932
940
// want to actually assert warnings about all this code. Instead
@@ -1021,7 +1029,7 @@ impl<'test> TestCx<'test> {
1021
1029
. args ( & self . props . compile_flags )
1022
1030
. args ( & self . props . doc_flags ) ;
1023
1031
1024
- if self . config . mode == RustdocJson {
1032
+ if self . config . mode == TestMode :: RustdocJson {
1025
1033
rustdoc. arg ( "--output-format" ) . arg ( "json" ) . arg ( "-Zunstable-options" ) ;
1026
1034
}
1027
1035
@@ -1372,7 +1380,7 @@ impl<'test> TestCx<'test> {
1372
1380
|| self . is_vxworks_pure_static ( )
1373
1381
|| self . config . target . contains ( "bpf" )
1374
1382
|| !self . config . target_cfg ( ) . dynamic_linking
1375
- || matches ! ( self . config. mode, CoverageMap | CoverageRun )
1383
+ || matches ! ( self . config. mode, TestMode :: CoverageMap | TestMode :: CoverageRun )
1376
1384
{
1377
1385
// We primarily compile all auxiliary libraries as dynamic libraries
1378
1386
// to avoid code size bloat and large binaries as much as possible
@@ -1562,14 +1570,14 @@ impl<'test> TestCx<'test> {
1562
1570
rustc. args ( & [ "-Z" , "incremental-verify-ich" ] ) ;
1563
1571
}
1564
1572
1565
- if self . config . mode == CodegenUnits {
1573
+ if self . config . mode == TestMode :: CodegenUnits {
1566
1574
rustc. args ( & [ "-Z" , "human_readable_cgu_names" ] ) ;
1567
1575
}
1568
1576
}
1569
1577
1570
1578
if self . config . optimize_tests && !is_rustdoc {
1571
1579
match self . config . mode {
1572
- Ui => {
1580
+ TestMode :: Ui => {
1573
1581
// If optimize-tests is true we still only want to optimize tests that actually get
1574
1582
// executed and that don't specify their own optimization levels.
1575
1583
// Note: aux libs don't have a pass-mode, so they won't get optimized
@@ -1585,8 +1593,8 @@ impl<'test> TestCx<'test> {
1585
1593
rustc. arg ( "-O" ) ;
1586
1594
}
1587
1595
}
1588
- DebugInfo => { /* debuginfo tests must be unoptimized */ }
1589
- CoverageMap | CoverageRun => {
1596
+ TestMode :: DebugInfo => { /* debuginfo tests must be unoptimized */ }
1597
+ TestMode :: CoverageMap | TestMode :: CoverageRun => {
1590
1598
// Coverage mappings and coverage reports are affected by
1591
1599
// optimization level, so they ignore the optimize-tests
1592
1600
// setting and set an optimization level in their mode's
@@ -1607,7 +1615,7 @@ impl<'test> TestCx<'test> {
1607
1615
} ;
1608
1616
1609
1617
match self . config . mode {
1610
- Incremental => {
1618
+ TestMode :: Incremental => {
1611
1619
// If we are extracting and matching errors in the new
1612
1620
// fashion, then you want JSON mode. Old-skool error
1613
1621
// patterns still match the raw compiler output.
@@ -1620,7 +1628,7 @@ impl<'test> TestCx<'test> {
1620
1628
rustc. arg ( "-Zui-testing" ) ;
1621
1629
rustc. arg ( "-Zdeduplicate-diagnostics=no" ) ;
1622
1630
}
1623
- Ui => {
1631
+ TestMode :: Ui => {
1624
1632
if !self . props . compile_flags . iter ( ) . any ( |s| s. starts_with ( "--error-format" ) ) {
1625
1633
rustc. args ( & [ "--error-format" , "json" ] ) ;
1626
1634
rustc. args ( & [ "--json" , "future-incompat" ] ) ;
@@ -1633,7 +1641,7 @@ impl<'test> TestCx<'test> {
1633
1641
// FIXME: use this for other modes too, for perf?
1634
1642
rustc. arg ( "-Cstrip=debuginfo" ) ;
1635
1643
}
1636
- MirOpt => {
1644
+ TestMode :: MirOpt => {
1637
1645
// We check passes under test to minimize the mir-opt test dump
1638
1646
// if files_for_miropt_test parses the passes, we dump only those passes
1639
1647
// otherwise we conservatively pass -Zdump-mir=all
@@ -1663,7 +1671,7 @@ impl<'test> TestCx<'test> {
1663
1671
1664
1672
set_mir_dump_dir ( & mut rustc) ;
1665
1673
}
1666
- CoverageMap => {
1674
+ TestMode :: CoverageMap => {
1667
1675
rustc. arg ( "-Cinstrument-coverage" ) ;
1668
1676
// These tests only compile to LLVM IR, so they don't need the
1669
1677
// profiler runtime to be present.
@@ -1673,23 +1681,28 @@ impl<'test> TestCx<'test> {
1673
1681
// by `compile-flags`.
1674
1682
rustc. arg ( "-Copt-level=2" ) ;
1675
1683
}
1676
- CoverageRun => {
1684
+ TestMode :: CoverageRun => {
1677
1685
rustc. arg ( "-Cinstrument-coverage" ) ;
1678
1686
// Coverage reports are sometimes sensitive to optimizations,
1679
1687
// and the current snapshots assume `opt-level=2` unless
1680
1688
// overridden by `compile-flags`.
1681
1689
rustc. arg ( "-Copt-level=2" ) ;
1682
1690
}
1683
- Assembly | Codegen => {
1691
+ TestMode :: Assembly | TestMode :: Codegen => {
1684
1692
rustc. arg ( "-Cdebug-assertions=no" ) ;
1685
1693
}
1686
- Crashes => {
1694
+ TestMode :: Crashes => {
1687
1695
set_mir_dump_dir ( & mut rustc) ;
1688
1696
}
1689
- CodegenUnits => {
1697
+ TestMode :: CodegenUnits => {
1690
1698
rustc. arg ( "-Zprint-mono-items" ) ;
1691
1699
}
1692
- Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake | RustdocJs => {
1700
+ TestMode :: Pretty
1701
+ | TestMode :: DebugInfo
1702
+ | TestMode :: Rustdoc
1703
+ | TestMode :: RustdocJson
1704
+ | TestMode :: RunMake
1705
+ | TestMode :: RustdocJs => {
1693
1706
// do not use JSON output
1694
1707
}
1695
1708
}
@@ -1962,7 +1975,7 @@ impl<'test> TestCx<'test> {
1962
1975
/// The revision, ignored for incremental compilation since it wants all revisions in
1963
1976
/// the same directory.
1964
1977
fn safe_revision ( & self ) -> Option < & str > {
1965
- if self . config . mode == Incremental { None } else { self . revision }
1978
+ if self . config . mode == TestMode :: Incremental { None } else { self . revision }
1966
1979
}
1967
1980
1968
1981
/// Gets the absolute path to the directory where all output for the given
0 commit comments