@@ -3,7 +3,11 @@ use crate::config::{Config, TargetSelection};
33use std:: thread;
44
55fn configure ( cmd : & str , host : & [ & str ] , target : & [ & str ] ) -> Config {
6- let mut config = Config :: parse ( & [ cmd. to_owned ( ) ] ) ;
6+ configure_with_args ( & [ cmd. to_owned ( ) ] , host, target)
7+ }
8+
9+ fn configure_with_args ( cmd : & [ String ] , host : & [ & str ] , target : & [ & str ] ) -> Config {
10+ let mut config = Config :: parse ( cmd) ;
711 // don't save toolstates
812 config. save_toolstates = None ;
913 config. dry_run = true ;
@@ -46,11 +50,39 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache {
4650 builder. cache
4751}
4852
53+ fn check_cli < const N : usize > ( paths : [ & str ; N ] ) {
54+ run_build (
55+ & paths. map ( PathBuf :: from) ,
56+ configure_with_args ( & paths. map ( String :: from) , & [ "A" ] , & [ "A" ] ) ,
57+ ) ;
58+ }
59+
60+ #[ test]
61+ fn test_valid ( ) {
62+ // make sure multi suite paths are accepted
63+ check_cli ( [ "test" , "src/test/ui/attr-start.rs" , "src/test/ui/attr-shebang.rs" ] ) ;
64+ }
65+
66+ #[ test]
67+ #[ should_panic]
68+ fn test_invalid ( ) {
69+ // make sure that invalid paths are caught, even when combined with valid paths
70+ check_cli ( [ "test" , "library/std" , "x" ] ) ;
71+ }
72+
4973#[ test]
5074fn test_intersection ( ) {
51- let set = PathSet :: Set ( [ "library/core" , "library/alloc" , "library/std" ] . into_iter ( ) . map ( TaskPath :: parse) . collect ( ) ) ;
52- let subset = set. intersection ( & [ Path :: new ( "library/core" ) , Path :: new ( "library/alloc" ) , Path :: new ( "library/stdarch" ) ] , None ) ;
53- assert_eq ! ( subset, PathSet :: Set ( [ "library/core" , "library/alloc" ] . into_iter( ) . map( TaskPath :: parse) . collect( ) ) ) ;
75+ let set = PathSet :: Set (
76+ [ "library/core" , "library/alloc" , "library/std" ] . into_iter ( ) . map ( TaskPath :: parse) . collect ( ) ,
77+ ) ;
78+ let mut command_paths =
79+ vec ! [ Path :: new( "library/core" ) , Path :: new( "library/alloc" ) , Path :: new( "library/stdarch" ) ] ;
80+ let subset = set. intersection_removing_matches ( & mut command_paths, None ) ;
81+ assert_eq ! (
82+ subset,
83+ PathSet :: Set ( [ "library/core" , "library/alloc" ] . into_iter( ) . map( TaskPath :: parse) . collect( ) )
84+ ) ;
85+ assert_eq ! ( command_paths, vec![ Path :: new( "library/stdarch" ) ] ) ;
5486}
5587
5688#[ test]
0 commit comments