* date: fix `date -f dates.txt is failing`
This commit is a trivial followup for:
https://github.com/uutils/coreutils/pull/4917
and
https://github.com/uutils/parse_datetime/pull/12
The functionality to parse the datetime was moved into the parse_datetime
crate and the only (tiny) piece left is to call it from `date`.
It also adds the test-case from the original issue. I did not include
the two tests from PR#4917 because they appear to work even without
this change. I am happy to include them of course if prefered.
Closes: #4657
Thanks to Ben Schofield
* tests: tweak changes to test_date.rs to be more idiomatic
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
When building coreutils I got the following deprecation warning:
```
warning: use of deprecated method `chrono::NaiveDateTime::timestamp_subsec_nanos`: use `.and_utc().timestamp_subsec_nanos()` instead
--> tests/by-util/test_touch.rs:37:59
|
37 | ..._utc().timestamp(), tm.timestamp_subsec_nanos())
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: `coreutils` (test "tests") generated 1 warning
```
This commit fixes it.
* uniq: print version and help on stdout again
* uniq: format test
* uniq: replace redundant closure with fn
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* dd: check file is a dir for iflag directory
* Improve english
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* dd: stderr output checking for "iflag directory" testcase
* dd: replace #[cfg(unix)] with #[test]
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
A debug assertion was added to enforce "width >= goal" to catch
that case before a panic in linebreak.rs. A few warnings in linebreak.rs
were addressed as well, and some isize's that should always be positive
(if there's no width/goal bugs) were changed to usizes to catch bugs
earlier.
test_fmt_width is updated to test for the same result as GNU fmt
* hashsum: make tag conflicts with --text and --check
* hashsum: change the case in one of the gnu test
* build-gnu.sh: use symlink instead of copy
Plus: it won't cp new md5
* hashsum: also escape/unescape files with checks
Should fix tests/cksum/md5sum-bsd.sh
* improve the variable name
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Improve test
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Improve test
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* cp: improve the support of --attributes-only
* remove useless comments
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Add tests that stat symlinks
* Check follow first in stat
* Don't run tests on FreeBSD
It would be possible to get them to run on FreeBSD by avoiding
get_symlink_times, but the behavior we're testing is not
platform-specific, so it's fine to not test it on FreeBSD.
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
* Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying
* Add test
* Make every permission 4 octal digits
* Change test name to be more suggestive
* chmod: merge two args in test
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Note in particular that `args_override_self` would *NOT* work here,
since it would in all cases cause `options::NAME` to override itself,
or interfere with `trailing_var_arg`.
The testcase tries to write to the stdin pipe while the process under
test is simultaneously exiting with an error code. Naturally, this is a
race, and we should ignore any stdin write errors. However, adding this
feature to the list makes it even more unreadable, and adds no real
value, so let's skip the input data entirely.
This was a GNU behavior bug:
```console
$ LC_ALL=C shuf -er
shuf: no lines to repeat
[$? = 1]
$ cargo run shuf -er # old, bad (unexpected success)
$ cargo run shuf -er # new
shuf: no lines to repeat
[$? = 1]
```
If the first four decimal digits are zero, GNU dd elides them altogether.
Here's an execution on my PC:
```console
$ for i in $(seq 20000); do LC_ALL=C gnu_dd if=/dev/null of=/dev/null \
2>&1; done | grep copied | grep -E ' [0-9]e'
0 bytes copied, 1e-05 s, 0 B/s
0 bytes copied, 9e-06 s, 0.0 kB/s
```
Our implementation conforms to this, resulting in the following CI flake:
```
---- test_dd::test_final_stats_unspec stdout ----
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-gnu\debug\coreutils.exe dd
thread 'test_dd::test_final_stats_unspec' panicked at 'Stderr does not match regex:
0+0 records in
0+0 records out
0 bytes copied, 8e-05 s, 0.0 B/s
', tests\by-util\test_dd.rs:280:10
stack backtrace:
0: rust_begin_unwind
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src/panicking.rs:578:5
```
Of course, this is just an overly strict regex in the test. This was a
one-in-tenthousand flaky test.
See also 9995c637aa.
There is a race condition between the writing thread and the command.
It is easily possible that on the developer's machine, the writing
thread is always faster, filling the kernel's buffer of the stdin pipe,
thus succeeding the write. It is also easily possible that on the busy
CI machines, the child command runs first for whatever reason, and exits
early, thus killing the pipe, which causes the later write to fail. This
results in a flaky test. Let's prevent flaky tests.
The comment was introduced in commit 8320b1ec5f,
the test was introduced in commit c1f518e586
claiming to be about "failing GNU head tests".
However, a simple check reveals no such difference:
```console
$ echo -n a | hd
00000000 61 |a|
00000001
$ echo -n a | head | hd # GNU head
00000000 61 |a|
00000001
$ echo -n a | cargo run -- head | hd
00000000 61 |a|
00000001
$ echo -n a | busybox head | hd
00000000 61 |a|
00000001
$
```
Looking at the GNU tests directly, it seems that there is a similar, but different test.
* more handle errors with multiple files
* tests/more test refactor and new case
* tests/more new cases
* more: use show! and change exitstatus and adjust tests to new exitvalue
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
* stat: should fail without arguments #5928
* style and lint issue stat: should fail without arguments #5928
* style and lint issue stat: should fail without arguments #5928
* style and lint 2 issue stat: should fail without arguments #5928
---------
Co-authored-by: biplab5464 <biplab5464@outlook.com>
* unexpand: should allow multiple files #5852 and unexpand: show error message if a directory is specified #5845
* test file added for #5845#5852
* test case test_multiple_files improve
* cakebaker suggestion for a better code #5845#5852
---------
Co-authored-by: biplab5464 <biplab5464@outlook.com>
pinky, uptime and who are not supported on OpenBSD (no support of utmpx feature) => disable tests
for these tools on OpenBSD with conditional compilation
Signed-off-by: Laurent Cheylus <foxy@free.fr>
* fix: return error when input is dir
* test: when tsort is given a dir
* fix: do not need to mention tsort in error message
* test: using concrete directory name
* tsort: fix formatting in test
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Fix missing dependency to "process" to make it compile.
* fix issue of not forwarding stdout from strip program
* fix issue of applying "./" redundantly
* cargo fmt
* cp: --preserve should keep xattr
Should help with tests/cp/acl.sh
* Update tests/by-util/test_cp.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update tests/by-util/test_cp.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update tests/by-util/test_cp.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* cksum: stops when one of given files doesn't exist #5809
* removed printld cksum: stops when one of given files doesn't exist #5809
* formatting the code cksum: stops when one of given files doesn't exist #5809
* formatting the code cksum: stops when one of given files doesn't exist #5809
* set exist status cksum: stops when one of given files doesn't exist #5809
* code quality formatting issue cksum: stops when one of given files doesn't exist #5809
* tertsdiepraam idea cksum: stops when one of given files doesn't exist #5809
* one new test case and deleted duplicate show cksum: stops when one of given files doesn't exist #5809
* formatting the test cases cksum: stops when one of given files doesn't exist #5809
* Revert "formatting the test cases cksum: stops when one of given files doesn't exist #5809"
This reverts commit 8c382f1e8f.
* reverting the changes and committing again due to a mistake cksum: stops when one of given files doesn't exist #5809
---------
Co-authored-by: biplab5464 <biplab5464@outlook.com>
* ls: if acl are used, show the + in the perms
Tested by tests/mkdir/p-acl.sh
* CICD.yml: fix small formatting issue
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>