@@ -26,6 +26,49 @@ fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
26
26
v. into_iter ( ) . map ( |( a, _) | a) . collect :: < Vec < _ > > ( )
27
27
}
28
28
29
+ fn run_build ( paths : & [ PathBuf ] , config : Config ) -> Cache {
30
+ let kind = config. cmd . kind ( ) ;
31
+ let build = Build :: new ( config) ;
32
+ let builder = Builder :: new ( & build) ;
33
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( kind) , paths) ;
34
+ builder. cache
35
+ }
36
+
37
+ #[ test]
38
+ fn test_exclude ( ) {
39
+ let mut config = configure ( "test" , & [ "A" ] , & [ "A" ] ) ;
40
+ config. exclude = vec ! [ TaskPath :: parse( "src/tools/tidy" ) ] ;
41
+
42
+ let build = Build :: new ( config) ;
43
+ let builder = Builder :: new ( & build) ;
44
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Test ) , & [ ] ) ;
45
+
46
+ // Ensure we have really excluded tidy
47
+ assert ! ( !builder. cache. contains:: <test:: Tidy >( ) ) ;
48
+
49
+ // Ensure other tests are not affected.
50
+ assert ! ( builder. cache. contains:: <test:: RustdocUi >( ) ) ;
51
+ }
52
+
53
+ #[ test]
54
+ fn test_exclude_kind ( ) {
55
+ let path = PathBuf :: from ( "src/tools/cargotest" ) ;
56
+ let exclude = TaskPath :: parse ( "test::src/tools/cargotest" ) ;
57
+ assert_eq ! ( exclude, TaskPath { kind: Some ( Kind :: Test ) , path: path. clone( ) } ) ;
58
+
59
+ let mut config = configure ( "test" , & [ "A" ] , & [ "A" ] ) ;
60
+ // Ensure our test is valid, and `test::Cargotest` would be run without the exclude.
61
+ assert ! ( run_build( & [ path. clone( ) ] , config. clone( ) ) . contains:: <test:: Cargotest >( ) ) ;
62
+ // Ensure tests for cargotest are skipped.
63
+ config. exclude = vec ! [ exclude. clone( ) ] ;
64
+ assert ! ( !run_build( & [ path. clone( ) ] , config) . contains:: <test:: Cargotest >( ) ) ;
65
+
66
+ // Ensure builds for cargotest are not skipped.
67
+ let mut config = configure ( "build" , & [ "A" ] , & [ "A" ] ) ;
68
+ config. exclude = vec ! [ exclude] ;
69
+ assert ! ( run_build( & [ path] , config) . contains:: <tool:: CargoTest >( ) ) ;
70
+ }
71
+
29
72
mod defaults {
30
73
use super :: { configure, first} ;
31
74
use crate :: builder:: * ;
@@ -515,35 +558,6 @@ mod dist {
515
558
) ;
516
559
}
517
560
518
- #[ test]
519
- fn test_exclude ( ) {
520
- let mut config = configure ( & [ "A" ] , & [ "A" ] ) ;
521
- config. exclude = vec ! [ TaskPath :: parse( "src/tools/tidy" ) ] ;
522
- config. cmd = Subcommand :: Test {
523
- paths : Vec :: new ( ) ,
524
- test_args : Vec :: new ( ) ,
525
- rustc_args : Vec :: new ( ) ,
526
- fail_fast : true ,
527
- doc_tests : DocTests :: No ,
528
- bless : false ,
529
- force_rerun : false ,
530
- compare_mode : None ,
531
- rustfix_coverage : false ,
532
- pass : None ,
533
- run : None ,
534
- } ;
535
-
536
- let build = Build :: new ( config) ;
537
- let builder = Builder :: new ( & build) ;
538
- builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Test ) , & [ ] ) ;
539
-
540
- // Ensure we have really excluded tidy
541
- assert ! ( !builder. cache. contains:: <test:: Tidy >( ) ) ;
542
-
543
- // Ensure other tests are not affected.
544
- assert ! ( builder. cache. contains:: <test:: RustdocUi >( ) ) ;
545
- }
546
-
547
561
#[ test]
548
562
fn doc_ci ( ) {
549
563
let mut config = configure ( & [ "A" ] , & [ "A" ] ) ;
0 commit comments