Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mktemp: add message for directory not found #3940

Merged
merged 2 commits into from
Sep 22, 2022

Conversation

jfinkels
Copy link
Collaborator

Add special handling in mktemp for when the directory that will
contain the temporary file is not found. This situation now produces
the message

mktemp: failed to create file via template 'XXX': No such file or directory

to match the behavior of GNU mktemp.

This fixes the test case pipe-bad-tmpdir in the GNU test suite file tests/misc/mktemp.pl.

@sylvestre
Copy link
Contributor

I guess you saw:



---- test_mktemp::test_nonexistent_dir_prefix stdout ----
current_directory_resolved: 
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe mktemp d/XXX
thread 'test_mktemp::test_nonexistent_dir_prefix' panicked at 'Command was expected to fail.
stdout = dwIl

 stderr = ', tests\common\util.rs:187:9

---- test_mktemp::test_nonexistent_tmpdir_env_var stdout ----
current_directory_resolved: 
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe mktemp
thread 'test_mktemp::test_nonexistent_tmpdir_env_var' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<mktemp: failed to create file via template 'C:\Users\RUNNER~1\AppData\Local\Temp\.tmpg3E5LO\no\such\dir\tmp.XXXXXXXXXX': No such file or directory
>mktemp: failed to create file via template 'no/such/dir/tmp.XXXXXXXXXX': No such file or directory

@jfinkels
Copy link
Collaborator Author

More Windows issues, of course :) I'll look into it

@jfinkels jfinkels force-pushed the mktemp-nonexistent-tmpdir-env-var branch from d800177 to b9b2ae2 Compare September 17, 2022 19:34
@jfinkels jfinkels force-pushed the mktemp-nonexistent-tmpdir-env-var branch from b9b2ae2 to 0764fba Compare September 17, 2022 21:51
@sylvestre
Copy link
Contributor

I guess you saw:

failures:

---- test_mktemp::test_nonexistent_dir_prefix stdout ----
current_directory_resolved: 
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-msvc\debug\coreutils.exe mktemp d\XXX
current_directory_resolved: 
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-msvc\debug\coreutils.exe mktemp -d d\XXX
thread 'test_mktemp::test_nonexistent_dir_prefix' panicked at 'mktemp: failed to create directory via template 'd\XXX': No such file or directory
', D:\a\coreutils\coreutils\tests\by-util\test_mktemp.rs:812:9

---- test_mktemp::test_nonexistent_tmpdir_env_var stdout ----
current_directory_resolved: 
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-msvc\debug\coreutils.exe mktemp
thread 'test_mktemp::test_nonexistent_tmpdir_env_var' panicked at 'mktemp: failed to create file via template 'C:\Users\RUNNER~1\AppData\Local\Temp\.tmpIKFkAF\no\such\dir\tmp.XXXXXXXXXX': No such file or directory
', D:\a\coreutils\coreutils\tests\by-util\test_mktemp.rs:753:9

@jfinkels
Copy link
Collaborator Author

Warning: Congrats! The gnu test tests/misc/mktemp is no longer failing!

Factor code out of `exec()` into two helper functions,
`make_temp_dir()` and `make_temp_file()`.
Add special handling in `mktemp` for when the directory that will
contain the temporary file is not found. This situation now produces
the message

    mktemp: failed to create file via template 'XXX': No such file or directory

to match the behavior of GNU mktemp.
@jfinkels jfinkels force-pushed the mktemp-nonexistent-tmpdir-env-var branch from d50f23c to 60ca9a0 Compare September 22, 2022 01:26
@sylvestre sylvestre merged commit 1e268b1 into uutils:main Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants