Skip to content

Commit 759eb42

Browse files
committed
Test force rebuild
1 parent 2a3d744 commit 759eb42

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/data/script-using-env.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let msg = option_env!("_RUST_SCRIPT_TEST_MESSAGE").unwrap_or("undefined");
2+
3+
println!("--output--");
4+
println!("msg = {}", msg);

tests/tests/script.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,34 @@ fn test_whitespace_before_main() {
186186
.unwrap()
187187
}
188188

189+
#[test]
190+
fn test_force_rebuild() {
191+
for option in ["-f", "--force"] {
192+
std::env::remove_var("_RUST_SCRIPT_TEST_MESSAGE");
193+
194+
let script_path = "tests/data/script-using-env.rs";
195+
let out = rust_script!(option, script_path).unwrap();
196+
scan!(out.stdout_output();
197+
("msg = undefined") => ()
198+
)
199+
.unwrap();
200+
201+
std::env::set_var("_RUST_SCRIPT_TEST_MESSAGE", "hello");
202+
203+
let out = rust_script!(script_path).unwrap();
204+
scan!(out.stdout_output();
205+
("msg = undefined") => ()
206+
)
207+
.unwrap();
208+
209+
let out = rust_script!(option, script_path).unwrap();
210+
scan!(out.stdout_output();
211+
("msg = hello") => ()
212+
)
213+
.unwrap();
214+
}
215+
}
216+
189217
#[test]
190218
#[ignore]
191219
fn test_stable_toolchain() {

0 commit comments

Comments
 (0)