@@ -99,9 +99,21 @@ struct StepDescription {
9999 name : & ' static str ,
100100}
101101
102+ /// Collection of paths used to match a task rule.
102103#[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
103104pub 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.
104110 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`.
105117 Suite ( PathBuf ) ,
106118}
107119
@@ -251,21 +263,33 @@ impl<'a> ShouldRun<'a> {
251263 self
252264 }
253265
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.
257275 pub fn all_krates ( mut self , name : & str ) -> Self {
258276 let mut set = BTreeSet :: new ( ) ;
259277 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) ;
261280 }
262281 self . paths . insert ( PathSet :: Set ( set) ) ;
263282 self
264283 }
265284
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.
266289 pub fn krate ( mut self , name : & str ) -> Self {
267290 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) ) ;
269293 }
270294 self
271295 }
@@ -488,13 +512,19 @@ impl<'a> Builder<'a> {
488512 should_run = ( desc. should_run ) ( should_run) ;
489513 }
490514 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+ } ;
491518 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+ }
498528 }
499529 }
500530 Some ( help)
0 commit comments