From: Stefano Lattarini Date: Wed, 27 Jul 2011 14:34:30 +0000 (+0200) Subject: testsuite: fix a spurious failure with non-bash shells X-Git-Tag: ng-0.5a~89^2~155^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24dd0449267486b3268ad812c5fda8b60dad1981;p=thirdparty%2Fautomake.git testsuite: fix a spurious failure with non-bash shells * tests/tap-fancy2.test: Remove an unportable use of backslashes with the `echo' builtin, which was causing some shells (among them bash and Debian /bin/ksh) to print a `\\' string, while other shells (among them zsh, dash, and Solaris /bin/sh and /bin/ksh) were unexpectedly printing a single `\' character. Since we are at it, add a sanity check to ensure that this issue does not resurface. --- diff --git a/ChangeLog b/ChangeLog index c1550e334..89b5059db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-07-27 Stefano Lattarini + + testsuite: fix a spurious failure with non-bash shells + * tests/tap-fancy2.test: Remove an unportable use of backslashes + with the `echo' builtin, which was causing some shells (among them + bash and Debian /bin/ksh) to print a `\\' string, while other + shells (among them zsh, dash, and Solaris /bin/sh and /bin/ksh) + were unexpectedly printing a single `\' character. Since we are + at it, add a sanity check to ensure that this issue does not + resurface. + 2011-07-27 Stefano Lattarini testsuite: fix spurious failures with Solaris /bin/sh diff --git a/tests/tap-fancy2.test b/tests/tap-fancy2.test index b97d787ea..977d38f4e 100755 --- a/tests/tap-fancy2.test +++ b/tests/tap-fancy2.test @@ -47,6 +47,9 @@ END # /#\s*(TODO|SKIP)\b/. # +# To avoid problems with backslashes in echo arguments. +xecho () { printf '%s\n' "$*"; } + # There are 34 values for $str ... for str in \ \' \ @@ -85,8 +88,8 @@ for str in \ '*.*' \ ; do # ... each of them add 1 pass, 1 fail, ... - echo "ok${str}" - echo "not ok${str}" + xecho "ok${str}" + xecho "not ok${str}" # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ... for settings in \ 'result="ok" directive=SKIP' \ @@ -94,17 +97,23 @@ for str in \ 'result="ok" directive=TODO' \ ; do eval "$settings" - echo "${result}# ${directive}${str}" + xecho "${result}# ${directive}${str}" # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since # they might not work with $str = '#' or $str = '\' ... if test x"$str" != x'#' && test x"$str" != x'\'; then - echo "${result}${str}#${directive}" - echo "${result}${str}# ${tab}${tab} ${directive}" - echo "${result}${str}#${directive}${str}" + xecho "${result}${str}#${directive}" + xecho "${result}${str}# ${tab}${tab} ${directive}" + xecho "${result}${str}#${directive}${str}" fi done done > all.test +# Sanity check against a previous use of unportable usages of backslashes +# with the "echo" builtin. +if grep '[^\\]\\#' all.test; then + framework_failure_ "writing backslashes in all.test" +fi + # ... so that we finally have: pass=34 fail=34