On Alpine Linux 3.12, 3.13, I see these test failures: FAIL: test-argp-2.sh FAIL: test-argp-version-etc-1.sh
They are caused by a 'diff' program that is not POSIX compliant: it produces unified diffs always and does not accept a '-c' nor a '-u' option. diff: unrecognized option: c BusyBox v1.32.1 () multi-call binary. Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2 This patch works around it, by using the 'compare' shell function from init.sh. 2021-01-17 Bruno Haible <br...@clisp.org> argp tests: Avoid test failures on Alpine Linux. * tests/test-argp-2.sh: Use the test framework (init.sh). Use the 'compare' function instead of 'diff -c'. * tests/test-argp-version-etc-1.sh: Likewise. diff --git a/tests/test-argp-2.sh b/tests/test-argp-2.sh index 9388c01..4a33fac 100755 --- a/tests/test-argp-2.sh +++ b/tests/test-argp-2.sh @@ -16,46 +16,48 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. */ -TMP=argp.$$ +. "${srcdir=.}/init.sh"; path_prepend_ . -unset ARGP_HELP_FMT ERR=0 +unset ARGP_HELP_FMT + func_compare() { # If argp was compiled without base_name, it will display full program name. # If run on mingw, it will display the program name with a .exe suffix. sed '1{ s,: [^ ]*/test-argp,: test-argp, s,: test-argp\.exe,: test-argp, - }' | LC_ALL=C tr -d '\r' | diff -c $TMP - + }' | LC_ALL=C tr -d '\r' > out + compare expected out } #### # Test --usage output -cat > $TMP <<EOT +cat > expected <<EOT Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test] [--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga] [--sonet] [--option] [--optional[=ARG]] [--many] [--one] [--two] [--limerick] [--poem] [--help] [--usage] [--version] ARGS... EOT -${CHECKER} ./test-argp${EXEEXT} --usage | func_compare || ERR=1 +${CHECKER} test-argp${EXEEXT} --usage | func_compare || ERR=1 #### # Test working usage-indent format -cat > $TMP <<EOT +cat > expected <<EOT Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test] [--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga] [--sonet] [--option] [--optional[=ARG]] [--many] [--one] [--two] [--limerick] [--poem] [--help] [--usage] [--version] ARGS... EOT -ARGP_HELP_FMT='usage-indent=0' ${CHECKER} ./test-argp${EXEEXT} --usage | func_compare || ERR=1 +ARGP_HELP_FMT='usage-indent=0' ${CHECKER} test-argp${EXEEXT} --usage | func_compare || ERR=1 #### # Test --help output -cat >$TMP <<EOT +cat >expected <<EOT Usage: test-argp [OPTION...] ARGS... documentation string @@ -96,18 +98,16 @@ Report bugs to <>. EOT # Compare --help output, but filter out any bug-reporting email address. -${CHECKER} ./test-argp${EXEEXT} --help \ +${CHECKER} test-argp${EXEEXT} --help \ | sed 's/^\(Report bugs to \)<[^>]*>.$/\1<>./' | func_compare || ERR=1 #### # Test ambiguous option handling -${CHECKER} ./test-argp${EXEEXT} --optio 2>/dev/null && ERR=1 +${CHECKER} test-argp${EXEEXT} --optio 2>/dev/null && ERR=1 #### # Run built-in tests -${CHECKER} ./test-argp${EXEEXT} || ERR=1 - -rm $TMP +${CHECKER} test-argp${EXEEXT} || ERR=1 -exit $ERR +Exit $ERR diff --git a/tests/test-argp-version-etc-1.sh b/tests/test-argp-version-etc-1.sh index 10b51d7..3ac4236 100755 --- a/tests/test-argp-version-etc-1.sh +++ b/tests/test-argp-version-etc-1.sh @@ -16,12 +16,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -TMP=ave-expected.tmp +. "${srcdir=.}/init.sh"; path_prepend_ . + +ERR=0 + LC_ALL=C export LC_ALL -ERR=0 -cat > $TMP <<EOT +cat > expected <<EOT test-argp-version-etc (PROJECT) VERSION COPYRIGHT Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. @@ -31,13 +33,12 @@ There is NO WARRANTY, to the extent permitted by law. Written by Sergey Poznyakoff. EOT -${CHECKER} ./test-argp-version-etc${EXEEXT} --version | +${CHECKER} test-argp-version-etc${EXEEXT} --version | sed '1s/test-argp-version-etc (.*) .*/test-argp-version-etc (PROJECT) VERSION/ /^Packaged by/d 2,3 s/Copyright (C) [0-9]\{4,4\}/COPYRIGHT/' | - tr -d '\015' | - diff -c $TMP - || ERR=1 + tr -d '\015' > output -rm $TMP +compare expected output || ERR=1 -exit $ERR +Exit $ERR