File tree Expand file tree Collapse file tree 2 files changed +89
-10
lines changed
Expand file tree Collapse file tree 2 files changed +89
-10
lines changed Original file line number Diff line number Diff line change @@ -608,16 +608,18 @@ impl CompileFilter {
608608 pub fn need_dev_deps ( & self , mode : CompileMode ) -> bool {
609609 match mode {
610610 CompileMode :: Test | CompileMode :: Doctest | CompileMode :: Bench => true ,
611- CompileMode :: Build | CompileMode :: Doc { .. } | CompileMode :: Check { .. } => match * self
612- {
613- CompileFilter :: Default { .. } => false ,
614- CompileFilter :: Only {
615- ref examples,
616- ref tests,
617- ref benches,
618- ..
619- } => examples. is_specific ( ) || tests. is_specific ( ) || benches. is_specific ( ) ,
620- } ,
611+ CompileMode :: Check { test : true } => true ,
612+ CompileMode :: Build | CompileMode :: Doc { .. } | CompileMode :: Check { test : false } => {
613+ match * self {
614+ CompileFilter :: Default { .. } => false ,
615+ CompileFilter :: Only {
616+ ref examples,
617+ ref tests,
618+ ref benches,
619+ ..
620+ } => examples. is_specific ( ) || tests. is_specific ( ) || benches. is_specific ( ) ,
621+ }
622+ }
621623 CompileMode :: RunCustomBuild => panic ! ( "Invalid mode" ) ,
622624 }
623625 }
Original file line number Diff line number Diff line change @@ -1108,3 +1108,80 @@ fn proc_macro_ws() {
11081108 . with_stderr_line_without ( & [ "[RUNNING] `rustc --crate-name foo" ] , & [ "--cfg[..]feat1" ] )
11091109 . run ( ) ;
11101110}
1111+
1112+ #[ cargo_test]
1113+ fn has_dev_dep_for_test ( ) {
1114+ // Check for a bug where the decision on whether or not "dev dependencies"
1115+ // should be used did not consider `check --profile=test`.
1116+ let p = project ( )
1117+ . file (
1118+ "Cargo.toml" ,
1119+ r#"
1120+ [package]
1121+ name = "foo"
1122+ version = "0.1.0"
1123+
1124+ [dev-dependencies]
1125+ dep = { path = 'dep', features = ['f1'] }
1126+ "# ,
1127+ )
1128+ . file (
1129+ "src/lib.rs" ,
1130+ r#"
1131+ #[test]
1132+ fn t1() {
1133+ dep::f();
1134+ }
1135+ "# ,
1136+ )
1137+ . file (
1138+ "dep/Cargo.toml" ,
1139+ r#"
1140+ [package]
1141+ name = "dep"
1142+ version = "0.1.0"
1143+
1144+ [features]
1145+ f1 = []
1146+ "# ,
1147+ )
1148+ . file (
1149+ "dep/src/lib.rs" ,
1150+ r#"
1151+ #[cfg(feature = "f1")]
1152+ pub fn f() {}
1153+ "# ,
1154+ )
1155+ . build ( ) ;
1156+
1157+ p. cargo ( "check -v" )
1158+ . with_stderr (
1159+ "\
1160+ [CHECKING] foo v0.1.0 [..]
1161+ [RUNNING] `rustc --crate-name foo [..]
1162+ [FINISHED] [..]
1163+ " ,
1164+ )
1165+ . run ( ) ;
1166+ p. cargo ( "check -v --profile=test -Zfeatures=dev_dep" )
1167+ . masquerade_as_nightly_cargo ( )
1168+ . with_stderr (
1169+ "\
1170+ [CHECKING] dep v0.1.0 [..]
1171+ [RUNNING] `rustc --crate-name dep [..]
1172+ [CHECKING] foo v0.1.0 [..]
1173+ [RUNNING] `rustc --crate-name foo [..]
1174+ [FINISHED] [..]
1175+ " ,
1176+ )
1177+ . run ( ) ;
1178+ p. cargo ( "check -v --profile=test" )
1179+ . with_stderr (
1180+ "\
1181+ [FRESH] dep [..]
1182+ [FRESH] foo [..]
1183+ [FINISHED] [..]
1184+ " ,
1185+ )
1186+ . run ( ) ;
1187+ }
You can’t perform that action at this time.
0 commit comments