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.
This commit is contained in:
Collin Funk committed 2026-10-24 12:22:36 -07:00
1 parent 9cad3af5ce
commit e78a41cf8f
3 files changed
+46

No files matched your search

+4
View File
@@ -16,6 +16,10 @@ GNU coreutils NEWS -*- outline -*-
the \u0085 (next line) character as a separator on non-GLIBC platforms.
[bug introduced in coreutils-9.11]
'date -u MMDDhhmm' no longer uses the local time zone's UTC offset when
setting the date and time.
[bug introduced in coreutils-9.11]
'factor' no longer treats inputs requiring the use of arbitrary-precision
integers followed by a non-numeric suffix as zero if the suffix includes
non-space characters, or the number itself when followed by spaces.
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
# Test that 'date' sets the date properly.
# Copyright (C) 2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ date
skip_if_root_
getlimits_
# In coreutils-9.11 and coreutils-9.12, TZ="..." date -u MMDDhhmm
# would use the UTC offset from $TZ instead of UTC0. While we are
# here, check the other methods of setting the date.
date -u -d '2026-01-01 12:00' >exp-out || fail=1
echo "date: cannot set date: $EPERM" >exp-err || framework_failure_
for opt in '' -s --set; do
if test -z "$opt"; then
date_str=0101120026
else
date_str='2026-01-01 12:00'
fi
returns_ 1 env TZ='America/Los_Angeles' date -u $opt "$date_str" >out 2>err \
|| fail=1
compare exp-out out || fail=1
compare exp-err err || fail=1
done
Exit $fail
+1
View File
@@ -356,6 +356,7 @@ all_tests = \
tests/date/date-ethiopia.sh \
tests/date/date-iran.sh \
tests/date/date-locale-hour.sh \
tests/date/date-set.sh \
tests/date/percent-percent.sh \
tests/date/reference.sh \
tests/date/resolution.sh \