File tree 1 file changed +60
-0
lines changed
1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,66 @@ use cargo_test_support::project;
5
5
use cargo_test_support:: sleep_ms;
6
6
use cargo_test_support:: str;
7
7
8
+ #[ cargo_test]
9
+ fn rerun_if_env_changes_config ( ) {
10
+ let p = project ( )
11
+ . file ( "Cargo.toml" , & basic_manifest ( "foo" , "0.1.0" ) )
12
+ . file ( "src/main.rs" , "fn main() {}" )
13
+ . file (
14
+ ".cargo/config.toml" ,
15
+ r#"
16
+ [env]
17
+ FOO = "good"
18
+ "# ,
19
+ )
20
+ . file (
21
+ "build.rs" ,
22
+ r#"
23
+ fn main() {
24
+ println!("cargo:rerun-if-env-changed=FOO");
25
+ if let Ok(foo) = std::env::var("FOO") {
26
+ assert!(&foo != "bad");
27
+ }
28
+ }
29
+ "# ,
30
+ )
31
+ . build ( ) ;
32
+
33
+ p. cargo ( "check" )
34
+ . with_stderr_data ( str![ [ r#"
35
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
36
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
37
+
38
+ "# ] ] )
39
+ . run ( ) ;
40
+
41
+ p. change_file (
42
+ ".cargo/config.toml" ,
43
+ r#"
44
+ [env]
45
+ FOO = "bad"
46
+ "# ,
47
+ ) ;
48
+
49
+ p. cargo ( "check" )
50
+ . with_stderr_data ( str![ [ r#"
51
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
52
+
53
+ "# ] ] )
54
+ . run ( ) ;
55
+
56
+ p. cargo ( "clean" ) . run ( ) ;
57
+ p. cargo ( "check" )
58
+ . with_status ( 101 )
59
+ . with_stderr_data (
60
+ "\
61
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
62
+ [ERROR] failed to run custom build command for `foo v0.1.0 ([..])`
63
+ ..." ,
64
+ )
65
+ . run ( ) ;
66
+ }
67
+
8
68
#[ cargo_test]
9
69
fn rerun_if_env_changes ( ) {
10
70
let p = project ( )
You can’t perform that action at this time.
0 commit comments