Commit Graph
292 Commits
Author SHA1 Message Date
Sylvestre Ledru 9e60b07a7c tests: date: test the '+' flag more thoroughly
* tests/date/date.pl: Check that '+' adds a sign only to year
conversions (%C, %y, %Y, %G, %F) whose width or value exceeds their
usual width, that it acts like '0' on other conversions, and that a
later '-', '_' or '0' flag cancels the sign.
https://github.com/uutils/coreutils/pull/16246

Link: https://github.com/coreutils/coreutils/pull/448
2026-11-08 14:17:59 +00:00
Pádraig Brady f3d8e1ce30 tests: add extra protection to avoid changing system time
* tests/date/date-set.sh: Block "settime" syscalls with strace,
in case the test has (inherited) CAP_SYS_TIME.
2026-10-25 13:04:55 +00:00
Collin Funk e78a41cf8f tests: date: test that -u overrides the time zone when setting the time
This adds a test for the bug fixed by commit 9192fd32e (date: bring back
-u complexity with putenv, 2026-10-22).

* tests/date/date-set.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.
2026-10-24 12:22:36 -07:00
Collin Funk 98c8b158b6 tests: make checks for $LOCALE_FR and $LOCALE_FR_UTF8 consistent
* tests/cp/non-utf8-name.sh: Check for $LOCALE_FR and $LOCALE_FR_UTF8
being empty or the string "none".
* tests/date/percent-percent.sh: Likewise.
* tests/du/block-size.sh (test_unit): Likewise.
* tests/ls/non-utf8-hidden.sh: Likewise.
* tests/mktemp/bad-unicode.sh: Likewise.
* tests/sort/sort-unique.sh: Likewise.
* tests/df/problematic-chars.sh:  Check for $LOCALE_FR_UTF8 being empty
or the string "none".
* tests/expand/mb.sh: Likewise.
* tests/fold/fold-characters.sh: Likewise.
* tests/fold/fold-nbsp.sh: Likewise.
* tests/fold/fold-spaces.sh: Likewise.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/join/join-utf8.sh: Likewise.
* tests/misc/sleep.sh: Likewise.
* tests/nl/multibyte.sh: Likewise.
* tests/paste/multi-byte.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
* tests/unexpand/mb.sh: Likewise.
2026-10-04 15:31:59 -07:00
Pádraig Brady ae8c120c45 tests: date: avoid a false failure on NetBSD
The following errors were seen on NetBSD 11.99:

 Setting LC_CTYPE to 'de_DE' failed setlocale(3)
 Setting LC_MESSAGES to 'de_DE' failed setlocale(3)
 Setting LC_MONETARY to 'de_DE' failed setlocale(3)
 Setting LC_NUMERIC to 'de_DE' failed setlocale(3)
 Setting LC_TIME to 'de_DE' failed setlocale(3)

* tests/date/date.pl: Ignore setlocale() errors seen on NetBSD 11.99.
Reported at https://bugs.gnu.org/81923
2026-09-25 15:22:00 +01:00
Sylvestre Ledru 9b37456b93 tests: date: check --reference with a non-UTF-8 file name
Nothing covered passing --reference a file name that is not valid in the
current locale, which is fine since the name is passed through to stat
as-is.
Identified here:  https://github.com/uutils/coreutils/pull/14558

* tests/date/reference.sh: Add a test case, skipped when the file system
rejects such a name.

Link: https://github.com/coreutils/coreutils/pull/357
2026-09-22 14:36:10 +01:00
Sylvestre Ledru 85857f1eaa tests: date: check that composite specifiers ignore the '-' flag
* tests/date/date.pl: Add tests ensuring that %-D, %-F, %-T, %-R, %-r,
%-x and %-X keep the default padding of their sub-fields, while the
other flags and the field width still apply to the whole expansion.
https://github.com/uutils/coreutils/pull/14163

Link: https://github.com/coreutils/coreutils/pull/339
2026-08-31 12:38:01 +01:00
Collin Funk 6e812858bb tests: date: check that weekdays are ignored when given an explicit date
* tests/date/date.pl: Add some test cases.
* tests/date/date-debug.sh: Test the debug output for this case.
2026-07-22 21:52:56 -07:00
Collin Funk 17e6bfcc2b tests: date: remove a non-portable test
This test failure was seen on FreeBSD, NetBSD, and OpenBSD.

* tests/date/date-tz.sh: Remove the test case.
Reported by Bruno Haible.
2026-06-23 18:26:21 -07:00
Collin Funk da1d289554 tests: date: test -d with only a minus sign
* tests/date/date.pl (@Tests): Add the test case.
2026-06-16 20:20:36 -07:00
Collin Funk efeac27389 tests: date: test time zone format strings with space padding
* tests/date/date.pl (@Tests): Add a few test cases.
2026-06-14 16:19:06 -07:00
Collin Funk 2a7d111818 tests: date: test that multiple time zone abbreviations cause an error
* tests/date/date.pl (@Tests): Add two test cases.
2026-06-14 11:15:03 -07:00
Sylvestre Ledru e75940f675 tests: date: check date-string parsing corner cases
* tests/date/date.pl: Add tests covering a leading day-of-week name,
out-of-range zone minutes, two timezone tokens, a bare sign operand,
a trailing token after an @epoch operand, operand quoting in
diagnostics, and a '+N unit' suffix following a complete time.
* tests/date/date-tz.sh: Add tests covering daylight-saving gap,
and overlap local times.
Closes https://github.com/coreutils/coreutils/pull/284
2026-06-09 13:42:00 +01:00
Sylvestre Ledru 56ed0d516e tests: date: check fixed offset is anchored before relative items
A fixed-offset keyword such as 'UTC' must anchor the instant before
relative items are applied, so that '1970-01-01 UTC N seconds' is
exactly N seconds past the epoch even when the local zone observes
DST between the epoch and the result.

* tests/date/date-tz.sh: Add a relative-seconds-across-DST case.
https://github.com/coreutils/coreutils/pull/275
2026-06-02 11:45:52 +01:00
Collin Funk f3395e7a79 tests: date: test format options combined with format strings
* tests/date/date.pl (@Tests): Add a few test cases.
2026-05-15 00:49:01 -07:00
Collin Funk dcca2a53b3 tests: date: test the behavior with multiple --iso-8601 options
* tests/date/date.pl (@Tests): Add test cases.
2026-05-11 18:26:25 -07:00
Pádraig Brady 15211db43f tests: fix false failure with dash
* tests/date/date-locale-hour.sh: Just strip the char before the last x,
assuming it's going to be the newline output by `locale`.
dash doesn't support $'' within ${}.
2026-04-17 13:24:46 +01:00
Pádraig Brady e245adbbc7 tests: fix false failure on Centos 7
* tests/date/date-locale-hour.sh: Ensure `locale date_fmt`
is propagated exactly, even when it contains trailing new lines,
as was seen with Serbian locales on Centos 7.
2026-04-16 17:44:05 +01:00
Pádraig Brady 745f4000fe tests: date: fix false failure on OpenBSD 7.8
* tests/date/date.pl: Set the max supported year to INT_MAX.
Most systems support INT_MAX+1900, but mktime() on OpenBSD 7.8
limits the passed tm_year to INT_MAX.
Reported by Bruno Haible.
2026-04-07 23:17:36 +01:00
Sylvestre Ledru 374a14e841 tests: date: add large year test
* tests/date/date.pl: Add the test case.
Add test case for https://github.com/uutils/coreutils/issues/9774
to verify with large dates.
https://github.com/coreutils/coreutils/pull/237
2026-04-06 19:22:24 +01:00
Sylvestre Ledru 6c6bb37e2f tests: date: add timezone conversion test
*tests/date/date.pl: Add the test case.
Add test case for https://github.com/uutils/coreutils/issues/10800
to verify `date -u -d '10:30 UTC-05'` converts to 15:30 UTC.
2026-03-04 13:22:46 +00:00
Sylvestre Ledru 452bf39162 tests: date: add edge cases for modifiers
* tests/date/date.pl: Add the test case.
Add test cases for https://github.com/uutils/coreutils/issues/10957
2026-03-04 13:20:33 +00:00
Collin Funk fec63bfa03 tests: date: check that options can follow the format string
* tests/date/date.pl (@Tests): Add the test case.
2026-02-13 22:26:59 -08:00
Pádraig Brady b4c6e3cb7f tests: date: check dotted EU dates in combination
* tests/date/date.pl: Add other date elements
to ensure abbreviated dotted dates are parsed appropriately.
Corresponds to gnulib commit 451042cb76
2026-02-12 14:52:06 +00:00
Gabriel e2c7db6c70 date: add tests and NEWS for dd.mm.yy support
* NEWS: Mention the new feature.
* tests/date/date.pl: Add test cases.
2026-02-08 16:25:44 +00:00
Collin Funk 29cee19e18 tests: date: test that %% in the string is not replaced
* tests/date/percent-percent.sh: New file.
* tests/local.mk (all_tests): Add it.
2026-01-27 19:13:33 -08:00
Paul Eggert 23e696b0b2 maint: spelling fixes 2026-01-16 13:22:28 -08:00
Pádraig Brady 210c000b8c tests: date: test nested parenthesis comment handling
* tests/date/date.pl: Add test cases.
Suggested by Sylvestre Ledru.
2026-01-11 18:51:19 +00:00
Sylvestre Ledru b7613ac8ff tests: date: test parenthesis comment handling
* tests/date/date.pl: Add the check.
2026-01-07 19:58:55 -08:00
Collin Funk 73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08:00
Collin Funk 18405cb51a tests: date: improve locale tests
* tests/date/date-locale-hour.sh: Test that the default format of 10
random supported locales is the same as 'locale date_fmt'.
2025-12-24 18:41:34 -08:00
Collin Funk 45071c85b5 tests: date: add another locale test case
On a GNU/Linux system, we have the following:

    $ LC_ALL=en_US.UTF-8 date -u -d 1:00
    Sun Dec 14 01:00:00 AM UTC 2025
    $ LC_ALL=en_US.UTF-8 locale date_fmt
    %a %b %e %r %Z %Y
    $ LC_ALL=en_US.UTF-8 locale t_fmt_ampm
    %I:%M:%S %p

    $ LC_ALL=nl_NL.UTF-8 date -u -d 1:00
    zo 14 dec 2025  1:00:00 UTC
    $ LC_ALL=nl_NL.UTF-8 locale date_fmt
    %a %e %b %Y %k:%M:%S %Z

We respect the locales preference for a leading zero or leading space in
single digit hours.

* tests/date/date-locale-hour.sh: Check that the locales preference for
leading zeros or spaces in single digit hours is used.
2025-12-15 15:54:00 -08:00
Collin Funk 07b5679570 maint: fix a typo in comments
* tests/date/reference.sh: Fix typo; s/modiication/modification.
2025-11-12 10:59:08 -08:00
Collin Funk 6d273604d0 tests: date: avoid test failure on NetBSD
* tests/date/date-tz.sh: Allow date to fail with large values for TZ
since NetBSD's tzalloc function limits them to 256 bytes.
2025-11-01 10:49:05 -07:00
Pádraig Brady 5a00d0a651 tests: fix new date/resolution.sh test on macOS
* tests/date/resolution.sh: Fix comparison on systems with less than
nano second reslution, where we use sed to discard the redundant
trailing zeros output by date --resolution.
Reported by Bruno Haible on macOS.
2025-10-28 12:56:26 +00:00
Pádraig Brady 1dabab7027 tests: date: test --resolution and %-N
* tests/date/resolution.sh: New test for --resolution and %-N.
* tests/local.mk: Reference the new test.
2025-10-23 17:40:13 +01:00
Pádraig Brady 14d24f7a53 tests: date: test --reference
* tests/date/reference.sh: Ensure the -r option is tested.
* tests/local.mk: Add the test.
2025-10-23 17:40:12 +01:00
Collin FunkandPádraig Brady 1066d442c2 tests: date: check that the hour format of the current locale is used
* tests/date/date-locale-hour.sh: New file.
* tests/local.mk (all_tests): Add the new test.

Co-authored-by: Pádraig Brady <P@draigBrady.com>
2025-10-13 21:56:43 -07:00
Collin Funk 56eaa4ffc3 tests: date: add tests for the Ethiopian calendar
* tests/date/date-ethiopia.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Collin Funk a9cd174811 tests: date: add tests for the Solar Hijri calendar
* tests/date/date-iran.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Collin Funk 5ab05e5a36 tests: date: add tests for the Thai solar calendar
* tests/date/date-thailand.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-21 21:25:58 -07:00
Paul Eggert 5c5e8b4a98 date: port test to NetBSD 10
Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-gnulib/2025-06/msg00094.html
* tests/date/date-debug.sh: Also allow NetBSD 10 mktime behavior.
Although NetBSD contradicts POSIX, POSIX is likely wrong here and
I vaguely recall that there’s a POSIX correction in progress
that will allow the NetBSD behavior.
2025-06-10 13:03:40 -07:00
Paul Eggert 276c04905f build: update gnulib submodule to latest
* tests/date/date-debug.sh: Update to match current behavior
of Gnulib's parse-datetime module.
2025-06-08 23:56:27 -07:00
Pádraig Brady 3a5c9c5537 tests: add a test case for negative relative date
* tests/date/date.pl: To exercise option processing.
2025-04-23 12:47:54 +01:00
Pádraig Brady 28b176085f maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* gnulib: Update included in this commit as copyright years
are the only change from the previous gnulib commit.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2025-01-01 09:33:08 +00:00
Pádraig Brady a966dcdb69 maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* gnulib: Update included in this commit as copyright years
are the only change from the previous gnulib commit.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Manually update copyright year,
until we fully sync with gnulib at a later stage.
* tests/sample-test: Adjust to use the single most recent year.
2024-01-01 13:27:23 +00:00
Sylvestre Ledru 15925d0e5b tests: move tests to a directory per utility
* cfg.mk: Adjust syntax check exclusion paths.
* tests/local.mk: Adjust for renamed tests.
2023-06-19 13:12:37 +01:00
Jim Meyering 9609435c35 . 2005-08-13 17:36:34 +00:00
Jim Meyering db209f6c24 move a bunch of tests to ../misc/date 2005-08-13 14:45:45 +00:00
Jim Meyering 9d610b26f8 move a bunch of tests to ../misc/date 2005-08-13 14:42:03 +00:00