File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
crates/cargo-codspeed/tests Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ fn bench_failing_without_custom_flag(c: &mut Criterion) {
88 compile_error ! (
99 "custom_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
1010 ) ;
11+
12+ #[ cfg( rustflags_feature_flag) ]
13+ compile_error ! ( "rustflags_feature_flag was set" ) ;
1114 } )
1215 } ) ;
1316}
Original file line number Diff line number Diff line change 11fn main ( ) {
22 println ! ( "cargo::rustc-check-cfg=cfg(custom_feature_flag)" ) ;
3+ println ! ( "cargo::rustc-check-cfg=cfg(rustflags_feature_flag)" ) ;
34}
Original file line number Diff line number Diff line change @@ -33,3 +33,37 @@ fn test_cargo_config_rustflags() {
3333
3434 teardown ( tmp_dir) ;
3535}
36+
37+ #[ test]
38+ fn test_cargo_config_with_rustflags_env ( ) {
39+ let tmp_dir = setup ( "tests/cargo_config.in" , Project :: Simple ) ;
40+
41+ std:: env:: set_var ( "RUSTFLAGS" , "--cfg rustflags_feature_flag" ) ;
42+
43+ let output = Command :: new ( "cargo" )
44+ . arg ( "bench" )
45+ . arg ( "--no-run" )
46+ . current_dir ( & tmp_dir)
47+ . output ( )
48+ . expect ( "Failed to execute cargo bench" ) ;
49+ assert ! ( !output. status. success( ) ) ;
50+ let stdout = String :: from_utf8_lossy ( & output. stderr ) ;
51+ assert ! (
52+ stdout. contains( "rustflags_feature_flag was set" ) ,
53+ "Incorrect output: {stdout}"
54+ ) ;
55+
56+ // Test that cargo codspeed build also works with the custom flag
57+ let output = cargo_codspeed ( & tmp_dir)
58+ . arg ( "build" )
59+ . output ( )
60+ . expect ( "Failed to execute cargo codspeed build" ) ;
61+ assert ! ( !output. status. success( ) ) ;
62+ let stdout = String :: from_utf8_lossy ( & output. stderr ) ;
63+ assert ! (
64+ stdout. contains( "rustflags_feature_flag was set" ) ,
65+ "Incorrect output: {stdout}"
66+ ) ;
67+
68+ teardown ( tmp_dir) ;
69+ }
You can’t perform that action at this time.
0 commit comments