Skip to content

Commit

Permalink
Fix mktemp test for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Jun 22, 2023
1 parent 7732c2e commit 438f1b4
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tests/by-util/test_mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,32 +923,38 @@ fn test_missing_xs_tmpdir_template() {
#[test]
fn test_both_tmpdir_flags_present() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
let template = format!(".{MAIN_SEPARATOR}foobarXXXX");
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd
.env(TMPDIR, ".")
.arg("-p")
.arg(".")
.arg("nonsense")
.arg("--tmpdir")
.arg("foobarXXXX")
.succeeds()
.no_stderr()
.stdout_contains("/tmp/foobar");
.succeeds();
let filename = result.no_stderr().stdout_str().trim_end();
assert_matches_template!(&template, filename);
assert!(at.file_exists(filename));

scene
.ucmd()
.arg("-p")
.arg(".")
.arg("--tmpdir=foobarXXXX")
.arg("--tmpdir=doesnotexist")
.fails()
.no_stdout()
.stderr_contains("failed to create file via template");
scene
.ucmd()

let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd
.arg("--tmpdir")
.arg("foobarXXXX")
.arg("-p")
.arg(".")
.succeeds()
.no_stderr()
.stdout_contains("./foobar");
.succeeds();
let filename = result.no_stderr().stdout_str().trim_end();
assert_matches_template!(&template, filename);
assert!(at.file_exists(filename));
}

#[test]
Expand Down

0 comments on commit 438f1b4

Please sign in to comment.