@@ -111,27 +111,34 @@ struct StepDescription {
111111}
112112
113113#[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
114- struct PathSet {
115- set : BTreeSet < PathBuf > ,
114+ pub enum PathSet {
115+ Set ( BTreeSet < PathBuf > ) ,
116+ Suite ( PathBuf )
116117}
117118
118119impl PathSet {
119120 fn empty ( ) -> PathSet {
120- PathSet { set : BTreeSet :: new ( ) }
121+ PathSet :: Set ( BTreeSet :: new ( ) )
121122 }
122123
123124 fn one < P : Into < PathBuf > > ( path : P ) -> PathSet {
124125 let mut set = BTreeSet :: new ( ) ;
125126 set. insert ( path. into ( ) ) ;
126- PathSet { set }
127+ PathSet :: Set ( set)
127128 }
128129
129130 fn has ( & self , needle : & Path ) -> bool {
130- self . set . iter ( ) . any ( |p| p. ends_with ( needle) )
131+ match self {
132+ PathSet :: Set ( set) => set. iter ( ) . any ( |p| p. ends_with ( needle) ) ,
133+ PathSet :: Suite ( _) => false
134+ }
131135 }
132136
133137 fn path ( & self , builder : & Builder ) -> PathBuf {
134- self . set . iter ( ) . next ( ) . unwrap_or ( & builder. build . src ) . to_path_buf ( )
138+ match self {
139+ PathSet :: Set ( set) => set. iter ( ) . next ( ) . unwrap_or ( & builder. build . src ) . to_path_buf ( ) ,
140+ PathSet :: Suite ( path) => PathBuf :: from ( path)
141+ }
135142 }
136143}
137144
@@ -203,7 +210,10 @@ impl StepDescription {
203210 for path in paths {
204211 let mut attempted_run = false ;
205212 for ( desc, should_run) in v. iter ( ) . zip ( & should_runs) {
206- if let Some ( pathset) = should_run. pathset_for_path ( path) {
213+ if let Some ( suite) = should_run. is_suite_path ( path) {
214+ attempted_run = true ;
215+ desc. maybe_run ( builder, suite) ;
216+ } else if let Some ( pathset) = should_run. pathset_for_path ( path) {
207217 attempted_run = true ;
208218 desc. maybe_run ( builder, pathset) ;
209219 }
@@ -250,7 +260,7 @@ impl<'a> ShouldRun<'a> {
250260 for krate in self . builder . in_tree_crates ( name) {
251261 set. insert ( PathBuf :: from ( & krate. path ) ) ;
252262 }
253- self . paths . insert ( PathSet { set } ) ;
263+ self . paths . insert ( PathSet :: Set ( set) ) ;
254264 self
255265 }
256266
@@ -268,9 +278,21 @@ impl<'a> ShouldRun<'a> {
268278
269279 // multiple aliases for the same job
270280 pub fn paths ( mut self , paths : & [ & str ] ) -> Self {
271- self . paths . insert ( PathSet {
272- set : paths. iter ( ) . map ( PathBuf :: from) . collect ( ) ,
273- } ) ;
281+ self . paths . insert ( PathSet :: Set ( paths. iter ( ) . map ( PathBuf :: from) . collect ( ) ) ) ;
282+ self
283+ }
284+
285+ pub fn is_suite_path ( & self , path : & Path ) -> Option < & PathSet > {
286+ self . paths . iter ( ) . find ( |pathset| {
287+ match pathset {
288+ PathSet :: Suite ( p) => path. starts_with ( p) ,
289+ PathSet :: Set ( _) => false
290+ }
291+ } )
292+ }
293+
294+ pub fn suite_path ( mut self , suite : & str ) -> Self {
295+ self . paths . insert ( PathSet :: Suite ( PathBuf :: from ( suite) ) ) ;
274296 self
275297 }
276298
@@ -372,8 +394,10 @@ impl<'a> Builder<'a> {
372394 }
373395 let mut help = String :: from ( "Available paths:\n " ) ;
374396 for pathset in should_run. paths {
375- for path in pathset. set {
376- help. push_str ( format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ) ;
397+ if let PathSet :: Set ( set) = pathset{
398+ set. iter ( ) . for_each ( |path| help. push_str (
399+ format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( )
400+ ) )
377401 }
378402 }
379403 Some ( help)
@@ -404,6 +428,7 @@ impl<'a> Builder<'a> {
404428 parent : Cell :: new ( None ) ,
405429 } ;
406430
431+
407432 if kind == Kind :: Dist {
408433 assert ! ( !builder. config. test_miri, "Do not distribute with miri enabled.\n \
409434 The distributed libraries would include all MIR (increasing binary size).
0 commit comments