@@ -974,21 +974,21 @@ fn cfg_rustflags_normal_source() {
974
974
[RUNNING] `rustc [..] --cfg bar[..]`
975
975
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
976
976
" ) ) ;
977
-
977
+
978
978
assert_that ( p. cargo ( "build" ) . arg ( "--bin=a" ) . arg ( "-v" ) ,
979
979
execs ( ) . with_status ( 0 ) . with_stderr ( "\
980
980
[COMPILING] foo v0.0.1 ([..])
981
981
[RUNNING] `rustc [..] --cfg bar[..]`
982
982
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
983
983
" ) ) ;
984
-
984
+
985
985
assert_that ( p. cargo ( "build" ) . arg ( "--example=b" ) . arg ( "-v" ) ,
986
986
execs ( ) . with_status ( 0 ) . with_stderr ( "\
987
987
[COMPILING] foo v0.0.1 ([..])
988
988
[RUNNING] `rustc [..] --cfg bar[..]`
989
989
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
990
990
" ) ) ;
991
-
991
+
992
992
assert_that ( p. cargo ( "test" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
993
993
execs ( ) . with_status ( 0 ) . with_stderr ( "\
994
994
[COMPILING] foo v0.0.1 ([..])
@@ -997,7 +997,7 @@ fn cfg_rustflags_normal_source() {
997
997
[RUNNING] `rustc [..] --cfg bar[..]`
998
998
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
999
999
" ) ) ;
1000
-
1000
+
1001
1001
assert_that ( p. cargo ( "bench" ) . arg ( "--no-run" ) . arg ( "-v" ) ,
1002
1002
execs ( ) . with_status ( 0 ) . with_stderr ( "\
1003
1003
[COMPILING] foo v0.0.1 ([..])
@@ -1006,7 +1006,7 @@ fn cfg_rustflags_normal_source() {
1006
1006
[RUNNING] `rustc [..] --cfg bar[..]`
1007
1007
[FINISHED] release [optimized] target(s) in [..]
1008
1008
" ) ) ;
1009
-
1009
+
1010
1010
}
1011
1011
1012
1012
// target.'cfg(...)'.rustflags takes precedence over build.rustflags
@@ -1069,7 +1069,7 @@ fn cfg_rustflags_precedence() {
1069
1069
[RUNNING] `rustc [..] --cfg bar[..]`
1070
1070
[FINISHED] release [optimized] target(s) in [..]
1071
1071
" ) ) ;
1072
-
1072
+
1073
1073
}
1074
1074
1075
1075
#[ test]
@@ -1157,5 +1157,42 @@ fn target_rustflags_string_and_array_form2() {
1157
1157
[RUNNING] `rustc [..] --cfg foo[..]`
1158
1158
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1159
1159
" ) ) ;
1160
+ }
1161
+
1162
+ #[ test]
1163
+ fn two_matching_in_config ( ) {
1164
+ let p1 = project ( "foo" )
1165
+ . file ( "Cargo.toml" , r#"
1166
+ [package]
1167
+ name = "foo"
1168
+ version = "0.0.1"
1169
+ "# )
1170
+ . file ( ".cargo/config" , r#"
1171
+ [target.'cfg(unix)']
1172
+ rustflags = ["--cfg", 'foo="a"']
1173
+ [target.'cfg(windows)']
1174
+ rustflags = ["--cfg", 'foo="a"']
1175
+ [target.'cfg(target_pointer_width = "32")']
1176
+ rustflags = ["--cfg", 'foo="b"']
1177
+ [target.'cfg(target_pointer_width = "64")']
1178
+ rustflags = ["--cfg", 'foo="b"']
1179
+ "# )
1180
+ . file ( "src/main.rs" , r#"
1181
+ fn main() {
1182
+ if cfg!(foo = "a") {
1183
+ println!("a");
1184
+ } else if cfg!(foo = "b") {
1185
+ println!("b");
1186
+ } else {
1187
+ panic!()
1188
+ }
1189
+ }
1190
+ "# )
1191
+ . build ( ) ;
1160
1192
1193
+ assert_that ( p1. cargo ( "run" ) , execs ( ) . with_status ( 0 ) ) ;
1194
+ assert_that ( p1. cargo ( "build" ) ,
1195
+ execs ( ) . with_status ( 0 ) . with_stderr ( "\
1196
+ [FINISHED] [..]
1197
+ " ) ) ;
1161
1198
}
0 commit comments