From: Pádraig Brady Date: Sun, 7 Sep 2025 12:09:06 +0000 (+0100) Subject: tests: ensure option aliases are supported X-Git-Tag: v9.8~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42c4578b49afaf3dc8de884262f34e4a19066860;p=thirdparty%2Fcoreutils.git tests: ensure option aliases are supported This implicitly tests the previous commit to adjust how date(1) handles multiple named format options. Currrently it tests the following are supported: chown --quiet --silent date --rfc-email --rfc-822 --rfc-2822 date --uct --utc --universal dircolors --bourne-shell --sh dircolors --csh --c-shell head --quiet --silent * tests/misc/option-aliases.sh: A new test to ensure all option aliases supported by a command are supported. * Reference the new test. --- diff --git a/tests/local.mk b/tests/local.mk index a42a20fbeb..885787c3a8 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -353,6 +353,7 @@ all_tests = \ tests/nproc/nproc-positive.sh \ tests/nproc/nproc-override.sh \ tests/misc/numfmt.pl \ + tests/misc/option-aliases.sh \ tests/od/od-N.sh \ tests/od/od-j.sh \ tests/od/od-multiple-t.sh \ diff --git a/tests/misc/option-aliases.sh b/tests/misc/option-aliases.sh new file mode 100755 index 0000000000..d1c4f4b6c8 --- /dev/null +++ b/tests/misc/option-aliases.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Make sure commands support all aliased options + +# Copyright (C) 2025 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 . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src + +# Restrict to GNU sed for now +sed --version | grep GNU >/dev/null || skip_ 'GNU sed required' + +rm -f failed || framework_failure_ + +for c in $abs_top_srcdir/src/*.c; do + cmd=$(basename "$c" '.c') + # extract option definitions + sed -n '/ long_options\[\]/,/};/p' "$c" | grep ', ' | + # ensure definitions on one line + sed ':a;/[^}],$/{N;s/[^}],\n/,/;ta}' | + # Strip comments + sed 's| */\*.*||' | + # append blank line after each repeated group + { uniq --all-repeated=separate -f3; echo; } | + # extract long options + cut -d'"' -f2 | + while read opt; do + if test "$opt"; then + opts="$opts --$opt " + else + if test "$opts"; then + case " $built_programs " in + *" $cmd "*) + $cmd $opts --version >/dev/null || touch failed ;; + *) + echo $cmd >> skipped ;; + esac + fi + opts='' + fi + done +done + +if test -f failed; then + fail=1 +elif test -f skipped; then + skip_ $(sort -u skipped | paste -s -d,) not built +fi + +Exit $fail