[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {GSoC} tests: fix a spurious failure with non-bash shells
From: |
Stefano Lattarini |
Subject: |
[FYI] {GSoC} tests: fix a spurious failure with non-bash shells |
Date: |
Wed, 27 Jul 2011 18:45:37 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
* 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.
---
ChangeLog | 11 +++++++++++
tests/tap-fancy2.test | 21 +++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7ff8cbe..272e4db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-07-27 Stefano Lattarini <address@hidden>
+ tests: 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 <address@hidden>
+
tests: fix spurious failures with Solaris /bin/sh
* tests/tap-more.test: Use `echo > file', not `: > file', to
create empty files in the "for" loops; this is required since,
diff --git a/tests/tap-fancy2.test b/tests/tap-fancy2.test
index b97d787..977d38f 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
--
1.7.2.3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [FYI] {GSoC} tests: fix a spurious failure with non-bash shells,
Stefano Lattarini <=