@@ -26,6 +26,49 @@ fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
2626 v. into_iter ( ) . map ( |( a, _) | a) . collect :: < Vec < _ > > ( )
2727}
2828
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+
2972mod defaults {
3073 use super :: { configure, first} ;
3174 use crate :: builder:: * ;
@@ -515,35 +558,6 @@ mod dist {
515558 ) ;
516559 }
517560
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-
547561 #[ test]
548562 fn doc_ci ( ) {
549563 let mut config = configure ( & [ "A" ] , & [ "A" ] ) ;
0 commit comments