@@ -3,7 +3,11 @@ use crate::config::{Config, TargetSelection};
3
3
use std:: thread;
4
4
5
5
fn 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) ;
7
11
// don't save toolstates
8
12
config. save_toolstates = None ;
9
13
config. dry_run = true ;
@@ -46,11 +50,39 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache {
46
50
builder. cache
47
51
}
48
52
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
+
49
73
#[ test]
50
74
fn 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" ) ] ) ;
54
86
}
55
87
56
88
#[ test]
0 commit comments