@@ -958,33 +958,55 @@ fn cfg_rustflags_normal_source() {
958
958
name = "foo"
959
959
version = "0.0.1"
960
960
"# )
961
- . file ( "src/lib.rs" , "" )
961
+ . file ( "src/lib.rs" , "pub fn t() {} " )
962
962
. file ( "src/bin/a.rs" , "fn main() {}" )
963
963
. file ( "examples/b.rs" , "fn main() {}" )
964
964
. file ( "tests/c.rs" , "#[test] fn f() { }" )
965
- . file ( "benches/d.rs" , r#"
966
- #![feature(test)]
967
- extern crate test;
968
- #[bench] fn run1(_ben: &mut test::Bencher) { }"# )
969
- . file ( ".cargo/config" , "
970
- [target.'cfg(feature=\" feat\" )']
971
- rustflags = [\" -Z\" , \" bogus\" ]
972
- " ) ;
965
+ . file ( ".cargo/config" , & format ! ( r#"
966
+ [target.'cfg({})']
967
+ rustflags = ["--cfg", "bar"]
968
+ "# , if rustc_host( ) . contains( "-windows-" ) { "windows" } else { "not(windows)" } ) ) ;
973
969
p. build ( ) ;
974
-
975
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
976
- . arg ( "--lib" ) ,
977
- execs ( ) . with_status ( 101 ) ) ;
978
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
979
- . arg ( "--bin=a" ) ,
980
- execs ( ) . with_status ( 101 ) ) ;
981
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
982
- . arg ( "--example=b" ) ,
983
- execs ( ) . with_status ( 101 ) ) ;
984
- assert_that ( p. cargo ( "test" ) . arg ( "--features" ) . arg ( "\" feat\" " ) ,
985
- execs ( ) . with_status ( 101 ) ) ;
986
- assert_that ( p. cargo ( "bench" ) . arg ( "--features" ) . arg ( "\" feat\" " ) ,
987
- execs ( ) . with_status ( 101 ) ) ;
970
+
971
+ assert_that ( p. cargo ( "build" ) . arg ( "--lib" ) . arg ( "-v" ) ,
972
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
973
+ [COMPILING] foo v0.0.1 ([..])
974
+ [RUNNING] `rustc [..] --cfg bar[..]`
975
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
976
+ " ) ) ;
977
+
978
+ assert_that ( p. cargo ( "build" ) . arg ( "--bin=a" ) . arg ( "-v" ) ,
979
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
980
+ [COMPILING] foo v0.0.1 ([..])
981
+ [RUNNING] `rustc [..] --cfg bar[..]`
982
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
983
+ " ) ) ;
984
+
985
+ assert_that ( p. cargo ( "build" ) . arg ( "--example=b" ) . arg ( "-v" ) ,
986
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
987
+ [COMPILING] foo v0.0.1 ([..])
988
+ [RUNNING] `rustc [..] --cfg bar[..]`
989
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
990
+ " ) ) ;
991
+
992
+ assert_that ( p. cargo ( "test" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
993
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
994
+ [COMPILING] foo v0.0.1 ([..])
995
+ [RUNNING] `rustc [..] --cfg bar[..]`
996
+ [RUNNING] `rustc [..] --cfg bar[..]`
997
+ [RUNNING] `rustc [..] --cfg bar[..]`
998
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
999
+ " ) ) ;
1000
+
1001
+ assert_that ( p. cargo ( "bench" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
1002
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1003
+ [COMPILING] foo v0.0.1 ([..])
1004
+ [RUNNING] `rustc [..] --cfg bar[..]`
1005
+ [RUNNING] `rustc [..] --cfg bar[..]`
1006
+ [RUNNING] `rustc [..] --cfg bar[..]`
1007
+ [FINISHED] release [optimized] target(s) in [..]
1008
+ " ) ) ;
1009
+
988
1010
}
989
1011
990
1012
// target.'cfg(...)'.rustflags takes precedence over build.rustflags
@@ -996,32 +1018,59 @@ fn cfg_rustflags_precedence() {
996
1018
name = "foo"
997
1019
version = "0.0.1"
998
1020
"# )
999
- . file ( "src/lib.rs" , "" )
1000
- . file ( ".cargo/config" , "
1021
+ . file ( "src/lib.rs" , "pub fn t() {}" )
1022
+ . file ( "src/bin/a.rs" , "fn main() {}" )
1023
+ . file ( "examples/b.rs" , "fn main() {}" )
1024
+ . file ( "tests/c.rs" , "#[test] fn f() { }" )
1025
+ . file ( ".cargo/config" , & format ! ( r#"
1001
1026
[build]
1002
- rustflags = [\ " --cfg\ " , \ " foo\ " ]
1027
+ rustflags = ["--cfg", "foo"]
1003
1028
1004
- [target.'cfg(feature = \" feat \" ') ]
1005
- rustflags = [\" -Z \ " , \" bogus \ " ]
1006
- " ) ;
1029
+ [target.'cfg({})' ]
1030
+ rustflags = ["--cfg ", "bar "]
1031
+ "# , if rustc_host ( ) . contains ( "-windows-" ) { "windows" } else { "not(windows)" } ) ) ;
1007
1032
p. build ( ) ;
1008
1033
1009
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
1010
- . arg ( "--lib" ) ,
1011
- execs ( ) . with_status ( 101 ) ) ;
1012
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
1013
- . arg ( "--bin=a" ) ,
1014
- execs ( ) . with_status ( 101 ) ) ;
1015
- assert_that ( p. cargo ( "build" ) . arg ( "--features" ) . arg ( "\" feat\" " )
1016
- . arg ( "--example=b" ) ,
1017
- execs ( ) . with_status ( 101 ) ) ;
1018
- assert_that ( p. cargo ( "test" ) . arg ( "--features" ) . arg ( "\" feat\" " ) ,
1019
- execs ( ) . with_status ( 101 ) ) ;
1020
- assert_that ( p. cargo ( "bench" ) . arg ( "--features" ) . arg ( "\" feat\" " ) ,
1021
- execs ( ) . with_status ( 101 ) ) ;
1022
- }
1034
+ assert_that ( p. cargo ( "build" ) . arg ( "--lib" ) . arg ( "-v" ) ,
1035
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1036
+ [COMPILING] foo v0.0.1 ([..])
1037
+ [RUNNING] `rustc [..] --cfg bar[..]`
1038
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1039
+ " ) ) ;
1040
+
1041
+ assert_that ( p. cargo ( "build" ) . arg ( "--bin=a" ) . arg ( "-v" ) ,
1042
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1043
+ [COMPILING] foo v0.0.1 ([..])
1044
+ [RUNNING] `rustc [..] --cfg bar[..]`
1045
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1046
+ " ) ) ;
1047
+
1048
+ assert_that ( p. cargo ( "build" ) . arg ( "--example=b" ) . arg ( "-v" ) ,
1049
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1050
+ [COMPILING] foo v0.0.1 ([..])
1051
+ [RUNNING] `rustc [..] --cfg bar[..]`
1052
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1053
+ " ) ) ;
1023
1054
1055
+ assert_that ( p. cargo ( "test" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
1056
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1057
+ [COMPILING] foo v0.0.1 ([..])
1058
+ [RUNNING] `rustc [..] --cfg bar[..]`
1059
+ [RUNNING] `rustc [..] --cfg bar[..]`
1060
+ [RUNNING] `rustc [..] --cfg bar[..]`
1061
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1062
+ " ) ) ;
1024
1063
1064
+ assert_that ( p. cargo ( "bench" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
1065
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1066
+ [COMPILING] foo v0.0.1 ([..])
1067
+ [RUNNING] `rustc [..] --cfg bar[..]`
1068
+ [RUNNING] `rustc [..] --cfg bar[..]`
1069
+ [RUNNING] `rustc [..] --cfg bar[..]`
1070
+ [FINISHED] release [optimized] target(s) in [..]
1071
+ " ) ) ;
1072
+
1073
+ }
1025
1074
1026
1075
#[ test]
1027
1076
fn target_rustflags_string_and_array_form1 ( ) {
0 commit comments