File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
crates/cargo-codspeed/tests Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 1
- [build ]
2
- rustflags = [" --cfg" , " custom_feature_flag" ]
1
+ # This will be generated by the test
Original file line number Diff line number Diff line change 1
- use std:: process:: Command ;
1
+ use std:: { path :: PathBuf , process:: Command } ;
2
2
3
3
mod helpers;
4
4
use helpers:: * ;
5
5
6
- #[ test]
7
- fn test_cargo_config_rustflags ( ) {
6
+ const BUILD_RUSTFLAGS : & str = r#"
7
+ [build]
8
+ rustflags = ["--cfg", "custom_feature_flag"]
9
+ "# ;
10
+
11
+ const TARGET_RUSTFLAGS : & str = r#"
12
+ [build]
13
+ rustflags = ["--cfg", "this_will_be_overridden"]
14
+
15
+ [target.'cfg(all())']
16
+ rustflags = ["--cfg=custom_feature_flag"]
17
+ "# ;
18
+
19
+ fn build_and_run_cargo_bench_with_config ( cargo_config : & str ) {
20
+ // Create a temporary directory and write the .cargo/config
8
21
let tmp_dir = setup ( "tests/cargo_config.in" , Project :: Simple ) ;
9
22
23
+ let config_path = PathBuf :: from ( & tmp_dir) . join ( ".cargo" ) . join ( "config.toml" ) ;
24
+ std:: fs:: create_dir_all ( config_path. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
25
+ std:: fs:: write ( config_path, cargo_config) . unwrap ( ) ;
26
+
10
27
// Test that cargo bench works with the custom flag
11
28
let output = Command :: new ( "cargo" )
12
29
. arg ( "bench" )
@@ -33,3 +50,13 @@ fn test_cargo_config_rustflags() {
33
50
34
51
teardown ( tmp_dir) ;
35
52
}
53
+
54
+ #[ test]
55
+ fn test_cargo_config_build_rustflags ( ) {
56
+ build_and_run_cargo_bench_with_config ( BUILD_RUSTFLAGS ) ;
57
+ }
58
+
59
+ #[ test]
60
+ fn test_cargo_config_target_rustflags ( ) {
61
+ build_and_run_cargo_bench_with_config ( TARGET_RUSTFLAGS ) ;
62
+ }
You can’t perform that action at this time.
0 commit comments