@@ -99,9 +99,21 @@ struct StepDescription {
99
99
name : & ' static str ,
100
100
}
101
101
102
+ /// Collection of paths used to match a task rule.
102
103
#[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
103
104
pub enum PathSet {
105
+ /// A collection of individual paths.
106
+ ///
107
+ /// These are generally matched as a path suffix. For example, a
108
+ /// command-line value of `libstd` will match if `src/libstd` is in the
109
+ /// set.
104
110
Set ( BTreeSet < PathBuf > ) ,
111
+ /// A "suite" of paths.
112
+ ///
113
+ /// These can match as a path suffix (like `Set`), or as a prefix. For
114
+ /// example, a command-line value of `src/test/ui/abi/variadic-ffi.rs`
115
+ /// will match `src/test/ui`. A command-line value of `ui` would also
116
+ /// match `src/test/ui`.
105
117
Suite ( PathBuf ) ,
106
118
}
107
119
@@ -251,21 +263,33 @@ impl<'a> ShouldRun<'a> {
251
263
self
252
264
}
253
265
254
- // Unlike `krate` this will create just one pathset. As such, it probably shouldn't actually
255
- // ever be used, but as we transition to having all rules properly handle passing krate(...) by
256
- // actually doing something different for every crate passed.
266
+ /// Indicates it should run if the command-line selects the given crate or
267
+ /// any of its (local) dependencies.
268
+ ///
269
+ /// Compared to `krate`, this treats the dependencies as aliases for the
270
+ /// same job. Generally it is preferred to use `krate`, and treat each
271
+ /// individual path separately. For example `./x.py test src/liballoc`
272
+ /// (which uses `krate`) will test just `liballoc`. However, `./x.py check
273
+ /// src/liballoc` (which uses `all_krates`) will check all of `libtest`.
274
+ /// `all_krates` should probably be removed at some point.
257
275
pub fn all_krates ( mut self , name : & str ) -> Self {
258
276
let mut set = BTreeSet :: new ( ) ;
259
277
for krate in self . builder . in_tree_crates ( name) {
260
- set. insert ( PathBuf :: from ( & krate. path ) ) ;
278
+ let path = krate. local_path ( self . builder ) ;
279
+ set. insert ( path) ;
261
280
}
262
281
self . paths . insert ( PathSet :: Set ( set) ) ;
263
282
self
264
283
}
265
284
285
+ /// Indicates it should run if the command-line selects the given crate or
286
+ /// any of its (local) dependencies.
287
+ ///
288
+ /// `make_run` will be called separately for each matching command-line path.
266
289
pub fn krate ( mut self , name : & str ) -> Self {
267
290
for krate in self . builder . in_tree_crates ( name) {
268
- self . paths . insert ( PathSet :: one ( & krate. path ) ) ;
291
+ let path = krate. local_path ( self . builder ) ;
292
+ self . paths . insert ( PathSet :: one ( path) ) ;
269
293
}
270
294
self
271
295
}
@@ -488,13 +512,19 @@ impl<'a> Builder<'a> {
488
512
should_run = ( desc. should_run ) ( should_run) ;
489
513
}
490
514
let mut help = String :: from ( "Available paths:\n " ) ;
515
+ let mut add_path = |path : & Path | {
516
+ help. push_str ( & format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) ) ;
517
+ } ;
491
518
for pathset in should_run. paths {
492
- if let PathSet :: Set ( set) = pathset {
493
- set. iter ( ) . for_each ( |path| {
494
- help. push_str (
495
- format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ,
496
- )
497
- } )
519
+ match pathset {
520
+ PathSet :: Set ( set) => {
521
+ for path in set {
522
+ add_path ( & path) ;
523
+ }
524
+ }
525
+ PathSet :: Suite ( path) => {
526
+ add_path ( & path. join ( "..." ) ) ;
527
+ }
498
528
}
499
529
}
500
530
Some ( help)
0 commit comments