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) {
8
8
compile_error ! (
9
9
"custom_feature_flag is not enabled - .cargo/config.toml rustflags not applied"
10
10
) ;
11
+
12
+ #[ cfg( rustflags_feature_flag) ]
13
+ compile_error ! ( "rustflags_feature_flag was set" ) ;
11
14
} )
12
15
} ) ;
13
16
}
Original file line number Diff line number Diff line change 1
1
fn main ( ) {
2
2
println ! ( "cargo::rustc-check-cfg=cfg(custom_feature_flag)" ) ;
3
+ println ! ( "cargo::rustc-check-cfg=cfg(rustflags_feature_flag)" ) ;
3
4
}
Original file line number Diff line number Diff line change @@ -33,3 +33,37 @@ fn test_cargo_config_rustflags() {
33
33
34
34
teardown ( tmp_dir) ;
35
35
}
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