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

Require = for --tmpdir in mktemp #4342

Merged
merged 4 commits into from
Jul 21, 2023
Merged

Conversation

tmccombs
Copy link
Contributor

Fixes #3454

This implementation more closely matches the behavior of GNU mktemp. Specifically, if using the short-form -p, then DIR is required, and if using the long form --tmpdir then DIR is optional, but if provided, must use the --tmpdir=DIR form (not --tempdir DIR), so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for clap-rs/clap#4702 where we use separate calls to .arg() for the short -p and the long --tmpdir, which results in a less than ideal output for --help.

@tertsdiepraam
Copy link
Member

Cool! Did you see #4275 already? Is this an improvement over that PR?

@tmccombs
Copy link
Contributor Author

I didn't see that other PR. I'm doing a review of it now. Overall, it looks pretty similar.

@tertsdiepraam
Copy link
Member

I commented the same on the other PR, but I like the approach here a bit better, as long it passes the same tests. So you could copy the tests from that PR (maybe with a co-author credit to @dmatos2012 in the commit).

@tmccombs tmccombs force-pushed the mktemp-req-equals branch 2 times, most recently from b3e358e to a02348e Compare February 13, 2023 07:01
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/misc/timeout. tests/misc/timeout is passing on 'main'. Maybe you have to rebase?

@dmatos2012
Copy link
Contributor

Hey @tmccombs @tertsdiepraam , yes I also think this PR is slightly cleaner with the override_with() clap argument, and mine is for sure older, so fine by me to use this one, but I would like indeed if the tests that I wrote I used that I get the co-author like @tertsdiepraam mentioned.

So good job, looking nice :)

@tertsdiepraam
Copy link
Member

I just see that you've also opened an issue at clap. If they want this functionality that's fine, but I don't think we need to push for this feature and complicate clap unnecessarily. For context, I've been working on a custom argument parser for uutils (see #4254). This is what mktemp looks like in that parser: https://github.com/tertsdiepraam/uutils-args/blob/main/tests/coreutils/mktemp.rs

@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still draft

@tertsdiepraam
Copy link
Member

Looks good! From my perspective, all that's missing is a co-author credit for @dmatos2012 in the test commit.

@sylvestre
Copy link
Contributor

Fails on Windows:

---- test_mktemp::test_both_tmpdir_flags_present stdout ----
run: D:\a\coreutils\coreutils\target\i686-pc-windows-msvc\debug\coreutils.exe mktemp -p . --tmpdir foobarXXXX
thread 'test_mktemp::test_both_tmpdir_flags_present' panicked at ''C:\Windows\foobarT7LG
' does not contain '/tmp/foobar'', tests\by-util\test_mktemp.rs:861:10
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\panicking.rs:142
   2: tests::common::util::CmdResult::stdout_contains<str>
             at .\tests\common\util.rs:653
   3: tests::test_mktemp::test_both_tmpdir_flags_present
             at .\tests\by-util\test_mktemp.rs:853
   4: tests::test_mktemp::test_both_tmpdir_flags_present::closure$0
             at .\tests\by-util\test_mktemp.rs:851
   5: core::ops::function::FnOnce::call_once<tests::test_mktemp::test_both_tmpdir_flags_present::closure_env$0,tuple$<> >
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52\library\core\src\ops\function.rs:248
   6: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\ops\function.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_mktemp::test_both_tmpdir_flags_present

@uutils uutils deleted a comment from github-actions bot Jun 20, 2023
Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please fix the conflict? thanks

@tmccombs tmccombs force-pushed the mktemp-req-equals branch 2 times, most recently from 6dc2993 to 438f1b4 Compare June 22, 2023 06:18
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail-2/inotify-dir-recreate

@tertsdiepraam
Copy link
Member

I'm trying to fix the test on windows to get this merged finally :)

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1
GNU test failed: tests/rm/rm2. tests/rm/rm2 is passing on 'main'. Maybe you have to rebase?

tmccombs and others added 3 commits July 18, 2023 12:46
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
And set overrides_with for tmpdir flags.

Tests were copied from uutils#4275

Co-authored-by: David Matos <[email protected]>
@sylvestre sylvestre merged commit e77a1bf into uutils:main Jul 21, 2023
@sylvestre
Copy link
Contributor

well done!

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.

mktemp: replace workaround code with features of clap 3
4 participants