Skip to content

Commit 292670e

Browse files
authored
Merge pull request #94 from fornwall/test-force-rebuild
Check for .exe on Windows
2 parents 656b372 + 100b041 commit 292670e

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,16 @@ impl InputAction {
339339

340340
let built_binary_path = platform::binary_cache_path()
341341
.join(if release_mode { "release" } else { "debug" })
342-
.join(&self.bin_name);
342+
.join({
343+
#[cfg(windows)]
344+
{
345+
format!("{}.exe", &self.bin_name)
346+
}
347+
#[cfg(not(windows))]
348+
{
349+
&self.bin_name
350+
}
351+
});
343352

344353
let manifest_path = self.manifest_path();
345354

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)