From 536db164bf119ac4624abcd2dcaa5542b4c830cf Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Tue, 11 Apr 2023 00:43:15 -0600 Subject: [PATCH] Fix mktemp test for windows --- tests/by-util/test_mktemp.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index db60d2453..0810fc43a 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -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]