]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: ls: cover two-line --time-style format assignment
authorSylvestre Ledru <sylvestre@debian.org>
Sun, 7 Jun 2026 09:43:43 +0000 (11:43 +0200)
committerPádraig Brady <P@draigBrady.com>
Tue, 9 Jun 2026 13:38:15 +0000 (14:38 +0100)
* tests/ls/ls-time.sh: Check that with a "FORMAT1 NEWLINE FORMAT2"
  --time-style, FORMAT1 is used for non-recent (old) files and FORMAT2
  for recent files.
  Identified here: https://github.com/uutils/coreutils/issues/12676
Closes https://github.com/coreutils/coreutils/pull/281

tests/ls/ls-time.sh

index 467c494cb70a67352c11da9bf0a88e86542eca29..1c8bf38020582f8b0ba56a1e089be1bfd0aebe3c 100755 (executable)
@@ -154,4 +154,14 @@ if gettext --version >/dev/null 2>&1; then
   fi
 fi
 
+# With a two-line --time-style format (FORMAT1 NEWLINE FORMAT2),
+# FORMAT1 applies to non-recent (old) files and FORMAT2 to recent files.
+touch -m recent || framework_failure_
+test $(($(date -r recent +%s) - $(date -r a +%s))) -gt $((31556952/2)) ||
+  framework_failure_
+ls -l --time-style="+old-%Y
+new-%Y" a recent >ts_out || fail=1
+grep -E "old-$(date -r a +%Y) a\$" ts_out &&
+grep -E "new-$(date -r recent +%Y) recent\$" ts_out || { cat ts_out; fail=1; }
+
 Exit $fail