From: Pádraig Brady Date: Tue, 28 Oct 2025 12:52:55 +0000 (+0000) Subject: tests: fix new date/resolution.sh test on macOS X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a00d0a651f40fe6257af42320438c3b88cdb363;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/tests/date/resolution.sh b/tests/date/resolution.sh index 730983dc99..4fbf4501f0 100755 --- a/tests/date/resolution.sh +++ b/tests/date/resolution.sh @@ -19,11 +19,12 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ date -# Ensure --resolution is supported +# Ensure --resolution is supported (prints to full nano second resolution) res=$(date --resolution) || fail=1 -# Ensure %-N format is supported -subsec1=$(printf "%s" "$res" | cut -d. -f2- | wc -c) || framework_failure_ +# Ensure %-N format is supported (prints to most concise resolution) +subsec1=$(printf '%s\n' "$res" | sed 's/.*\.//; s/0*$//' | wc -c) || + framework_failure_ subsec2=$(date +%-N | wc -c) || framework_failure_ test "$subsec1" = "$subsec2" || fail=1