diff options
| author | Pádraig Brady <P@draigBrady.com> | 2025-10-28 12:52:55 +0000 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2025-10-28 12:56:26 +0000 |
| commit | 5a00d0a651f40fe6257af42320438c3b88cdb363 (patch) | |
| tree | f66d21e3f0c73a3a273205f364623b46858f013b | |
| parent | numfmt: ensure fields don't split on nbsp (diff) | |
| download | coreutils-5a00d0a651f40fe6257af42320438c3b88cdb363.tar.gz coreutils-5a00d0a651f40fe6257af42320438c3b88cdb363.zip | |
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.
| -rwxr-xr-x | tests/date/resolution.sh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/date/resolution.sh b/tests/date/resolution.sh index 730983dc9..4fbf4501f 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 |
