@@ -2,141 +2,17 @@ use std::collections::{BTreeSet, HashMap, HashSet};
22use std:: ffi:: OsString ;
33use std:: path:: { Path , PathBuf } ;
44use std:: process:: Command ;
5- use std:: str:: FromStr ;
65use std:: sync:: OnceLock ;
7- use std:: { fmt , iter} ;
6+ use std:: iter;
87
98use build_helper:: git:: GitConfig ;
109use semver:: Version ;
1110use serde:: de:: { Deserialize , Deserializer , Error as _} ;
1211use test:: { ColorConfig , OutputFormat } ;
1312
14- pub use self :: Mode :: * ;
1513use crate :: util:: { PathBufExt , add_dylib_path} ;
14+ pub use build_helper:: compiletest:: * ;
1615
17- macro_rules! string_enum {
18- ( $( #[ $meta: meta] ) * $vis: vis enum $name: ident { $( $variant: ident => $repr: expr, ) * } ) => {
19- $( #[ $meta] ) *
20- $vis enum $name {
21- $( $variant, ) *
22- }
23-
24- impl $name {
25- $vis const VARIANTS : & ' static [ Self ] = & [ $( Self :: $variant, ) * ] ;
26- $vis const STR_VARIANTS : & ' static [ & ' static str ] = & [ $( Self :: $variant. to_str( ) , ) * ] ;
27-
28- $vis const fn to_str( & self ) -> & ' static str {
29- match self {
30- $( Self :: $variant => $repr, ) *
31- }
32- }
33- }
34-
35- impl fmt:: Display for $name {
36- fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
37- fmt:: Display :: fmt( self . to_str( ) , f)
38- }
39- }
40-
41- impl FromStr for $name {
42- type Err = String ;
43-
44- fn from_str( s: & str ) -> Result <Self , Self :: Err > {
45- match s {
46- $( $repr => Ok ( Self :: $variant) , ) *
47- _ => Err ( format!( concat!( "unknown `" , stringify!( $name) , "` variant: `{}`" ) , s) ) ,
48- }
49- }
50- }
51- }
52- }
53-
54- // Make the macro visible outside of this module, for tests.
55- #[ cfg( test) ]
56- pub ( crate ) use string_enum;
57-
58- string_enum ! {
59- #[ derive( Clone , Copy , PartialEq , Debug ) ]
60- pub enum Mode {
61- Pretty => "pretty" ,
62- DebugInfo => "debuginfo" ,
63- Codegen => "codegen" ,
64- Rustdoc => "rustdoc" ,
65- RustdocJson => "rustdoc-json" ,
66- CodegenUnits => "codegen-units" ,
67- Incremental => "incremental" ,
68- RunMake => "run-make" ,
69- Ui => "ui" ,
70- RustdocJs => "rustdoc-js" ,
71- MirOpt => "mir-opt" ,
72- Assembly => "assembly" ,
73- CoverageMap => "coverage-map" ,
74- CoverageRun => "coverage-run" ,
75- Crashes => "crashes" ,
76- }
77- }
78-
79- impl Default for Mode {
80- fn default ( ) -> Self {
81- Mode :: Ui
82- }
83- }
84-
85- impl Mode {
86- pub fn aux_dir_disambiguator ( self ) -> & ' static str {
87- // Pretty-printing tests could run concurrently, and if they do,
88- // they need to keep their output segregated.
89- match self {
90- Pretty => ".pretty" ,
91- _ => "" ,
92- }
93- }
94-
95- pub fn output_dir_disambiguator ( self ) -> & ' static str {
96- // Coverage tests use the same test files for multiple test modes,
97- // so each mode should have a separate output directory.
98- match self {
99- CoverageMap | CoverageRun => self . to_str ( ) ,
100- _ => "" ,
101- }
102- }
103- }
104-
105- string_enum ! {
106- #[ derive( Clone , Copy , PartialEq , Debug , Hash ) ]
107- pub enum PassMode {
108- Check => "check" ,
109- Build => "build" ,
110- Run => "run" ,
111- }
112- }
113-
114- #[ derive( Copy , Clone , Debug , PartialEq , PartialOrd ) ]
115- pub enum FailMode {
116- Check ,
117- Build ,
118- Run ,
119- }
120-
121- string_enum ! {
122- #[ derive( Clone , Debug , PartialEq ) ]
123- pub enum CompareMode {
124- Polonius => "polonius" ,
125- NextSolver => "next-solver" ,
126- NextSolverCoherence => "next-solver-coherence" ,
127- SplitDwarf => "split-dwarf" ,
128- SplitDwarfSingle => "split-dwarf-single" ,
129- }
130- }
131-
132- string_enum ! {
133- #[ derive( Clone , Copy , Debug , PartialEq ) ]
134- pub enum Debugger {
135- Cdb => "cdb" ,
136- Gdb => "gdb" ,
137- Lldb => "lldb" ,
138- }
139- }
14016
14117#[ derive( Clone , Copy , Debug , PartialEq , Default , serde:: Deserialize ) ]
14218#[ serde( rename_all = "kebab-case" ) ]
0 commit comments