@@ -33,7 +33,7 @@ impl ICE {
33
33
Ok ( Self { path, mode } )
34
34
}
35
35
36
- pub fn id ( & self ) -> usize {
36
+ pub fn id ( & self ) -> IssueId {
37
37
let s = self
38
38
. path
39
39
. file_stem ( )
@@ -43,7 +43,7 @@ impl ICE {
43
43
. unwrap ( ) ;
44
44
// Some files have names like 123-1.rs; only get the first part of it
45
45
let s = s. split ( '-' ) . next ( ) . unwrap ( ) ;
46
- s. parse ( ) . unwrap ( )
46
+ IssueId ( s. parse ( ) . unwrap ( ) )
47
47
}
48
48
49
49
fn test ( self ) -> Result < TestResult > {
@@ -80,6 +80,29 @@ impl ICE {
80
80
}
81
81
}
82
82
83
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
84
+ pub struct IssueId ( pub usize ) ;
85
+
86
+ /// Filters which ICEs should be tested.
87
+ #[ derive( Default ) ]
88
+ pub struct Filter {
89
+ ids : Vec < IssueId > ,
90
+ }
91
+
92
+ impl Filter {
93
+ pub fn try_from_args ( args : std:: env:: Args ) -> Result < Self > {
94
+ let ids = args
95
+ . skip ( 1 )
96
+ . map ( |arg| Ok ( IssueId ( arg. parse ( ) ?) ) )
97
+ . collect :: < Result < _ > > ( ) ?;
98
+ Ok ( Self { ids } )
99
+ }
100
+
101
+ pub fn matches ( & self , ice : & ICE ) -> bool {
102
+ self . ids . is_empty ( ) || self . ids . contains ( & ice. id ( ) )
103
+ }
104
+ }
105
+
83
106
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
84
107
pub enum Outcome {
85
108
NoError ,
@@ -200,7 +223,9 @@ pub fn discover(dir: &str) -> Result<Vec<ICE>> {
200
223
Ok ( ices)
201
224
}
202
225
203
- pub fn test_all ( ) -> Result < impl IndexedParallelIterator < Item = Result < TestResult > > > {
226
+ pub fn test_all_matching_filter (
227
+ filter : & Filter ,
228
+ ) -> Result < impl IndexedParallelIterator < Item = Result < TestResult > > > {
204
229
env:: set_var ( "RUSTUP_TOOLCHAIN" , "nightly" ) ;
205
230
206
231
let output = Command :: new ( "rustc" ) . arg ( "--version" ) . output ( ) ?;
@@ -209,13 +234,21 @@ pub fn test_all() -> Result<impl IndexedParallelIterator<Item = Result<TestResul
209
234
output. status. success( ) ,
210
235
"nightly toolchain is not installed, run `rustup install nightly`"
211
236
) ;
212
- let ices = discover ( ICES_PATH ) ?;
237
+ let all_ices = discover ( ICES_PATH ) ?;
238
+ let ices_to_test: Vec < ICE > = all_ices
239
+ . into_iter ( )
240
+ . filter ( |ice| filter. matches ( ice) )
241
+ . collect ( ) ;
213
242
214
243
eprintln ! (
215
244
"running {} tests for {}" ,
216
- ices . len( ) ,
245
+ ices_to_test . len( ) ,
217
246
String :: from_utf8_lossy( & output. stdout)
218
247
) ;
219
248
220
- Ok ( ices. into_par_iter ( ) . map ( |ice| ice. test ( ) ) )
249
+ Ok ( ices_to_test. into_par_iter ( ) . map ( |ice| ice. test ( ) ) )
250
+ }
251
+
252
+ pub fn test_all ( ) -> Result < impl IndexedParallelIterator < Item = Result < TestResult > > > {
253
+ test_all_matching_filter ( & Filter :: default ( ) )
221
254
}
0 commit comments