Commit Graph
90 Commits
Author SHA1 Message Date
oech3andoech3 d51d2faa0e touch: extent a test for many device files 2026-01-12 20:15:22 +09:00
Aaron Ang e58060927d fix: use jiff time for touch tests 2026-01-06 15:16:43 -08:00
16c16f44ee Use libc::UTIME_NOW in touch when updating time to now (#9870)
* Use libc::UTIME_NOW in touch when updating time to now

* Explicit libc import to satisfy clippy

* Fix location of cfg in touch

* Add cfg gate to libc import to satisfy clippy on windows

* Change cfg gates in touch near libc::UTIME_NOW from unix to linux

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-12-31 20:09:14 +01:00
Dmitry ShemetovandSylvestre Ledru 949f038b3b test: symlink differently on windows/not 2025-12-23 23:30:47 +01:00
Dmitry ShemetovandSylvestre Ledru a1596caa8c test: capture message with .stderr_contains 2025-12-23 23:30:47 +01:00
Dmitry ShemetovandSylvestre Ledru cf2fa7c556 fix: touch -r: dangling symlink reference is accepted Fixes #9703 2025-12-23 23:30:47 +01:00
Daniel Hofstetter 086795d26e touch: simplify some tests by using new_ucmd!() 2025-09-10 11:28:23 +02:00
Daniel Hofstetter 74ee8fb1c1 touch: adapt expected error message in test 2025-09-10 10:20:04 +02:00
Sylvestre Ledru 71b4de24e6 test: improve support non-utf-8 2025-08-14 10:54:04 +02:00
Sylvestre Ledru f15dac138e chmod/readlink/du: improve non-UTF-8 filename handling and code style 2025-08-14 10:52:24 +02:00
Sylvestre Ledru c0da27addc touch: fix handling of non-UTF-8 filenames 2025-08-14 10:52:24 +02:00
Daniel Hofstetter 7dc20bbdb0 touch: adapt tests to changes in parse_datetime 2025-08-01 10:23:30 +02:00
Dorian Peron 6e23d4e979 tests: patch tests to simplify imports 2025-07-01 03:36:46 +02:00
c64adee068 touch: add -f flag (#8274)
* touch: fix f flag

* Update src/uu/touch/src/touch.rs

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>

* touch: add test for f flag

* Update src/uu/touch/src/touch.rs

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

* Update tests/by-util/test_touch.rs

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

* remove unnecessary comment

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-06-29 15:26:33 +02:00
Yuri Astrakhan a27880e8a3 chore: use assert_eq! and assert_ne! instead of assert!
Makes intent clearer, and if something fails, prints the values that caused the failure as part of the panic message.
2025-04-08 13:25:41 -04:00
Yuri Astrakhan 982805d3cd chore: manual inline formatting
Minor manual cleanup - inlined many format args.  This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs.  Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).
2025-04-08 00:23:21 -04:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Sylvestre Ledru a85539f530 Run cargo fmt on the tree 2025-03-24 21:33:12 +01:00
M BussonnierandDorian Péron 57d0157c6a split test for 32 and 64 bits systems 2025-03-14 11:00:08 +01:00
M BussonnierandDorian Péron 7632acfc90 Fix touch -t with 2 digit years when YY > 68
When using `touch -t` with a 2 digit year, the year is interpreted as
a relative year to 2000.

When the year is 68 or less, it should be interpreted as 20xx.
When the year is 69 or more, it should be interpreted as 19xx.

This is the behavior of GNU `touch`.

fixes gh-7280

Arguably 2 digits years should be deprecated as we
are already closer to 2069, than 1969.
2025-03-14 11:00:08 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Jeffrey Finkelstein c23e1db9c5 Use the last, not first, two digits as the year 2025-02-06 22:02:47 -05:00
Jeffrey Finkelstein 6dfa1f8276 touch: support obsolete POSIX timestamp argument
Support obsolete form of timestamp argument for old POSIX versions. In
summary, when older versions of POSIX are used and the first positional
argument looks like a date and time, then treat it as a timestamp
instead of as a filename. For example, before this commit

    _POSIX2_VERSION=199209
    POSIXLY_CORRECT=1
    touch 01010000 11111111

would create two files, `01010000` and `11111111`. After this commit,
the first argument is interpreted as a date and time (in this case,
midnight on January 1 of the current year) and that date and time are
set on the file named `11111111`.

Fixes #7180.
2025-02-05 22:04:47 -05:00
Laurent Cheylus c25ba39ce6 tests: disable failed tests for touch on OpenBSD
Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-07-06 22:29:20 +02:00
n4n5 635ad16c63 touch: change message when trailing slash 2024-06-30 19:00:54 +02:00