[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] maintainer-check: warn against zsh xtrace bug
From: |
Stefano Lattarini |
Subject: |
[PATCH 2/3] maintainer-check: warn against zsh xtrace bug |
Date: |
Wed, 9 Dec 2009 14:15:38 +0100 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.2; i686; ; ) |
Extended target maintainer-check, to warn against idioms and
constructs in test scripts which might trigger the Zsh xtrace
bug.
* Makefile.am (sc_tests_stderr_redirection): New check.
(sc_tests_stderr_redirection__perl_code): New internal macro.
(sc_tests_stderr_redirection__whitelist): Likewise.
(syntax_check_rules): Added `sc_tests_stderr_redirection'.
From a6f89c12687e430094f47c3375ea9b72f159a409 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Tue, 8 Dec 2009 18:09:14 +0100
Subject: [PATCH 2/3] maintainer-check: warn against zsh xtrace bug
Extended target maintainer-check, to warn against idioms and
constructs in test scripts which might trigger the Zsh xtrace
bug.
* Makefile.am (sc_tests_stderr_redirection): New check.
(sc_tests_stderr_redirection__perl_code): New internal macro.
(sc_tests_stderr_redirection__whitelist): Likewise.
(syntax_check_rules): Added `sc_tests_stderr_redirection'.
---
ChangeLog | 10 +++++++++
Makefile.am | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Makefile.in | 44 +++++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2d5791a..bf9d364 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-08 Stefano Lattarini <address@hidden>
+
+ Extended target maintainer-check, to warn against idioms and
+ constructs in test scripts which might trigger the Zsh xtrace
+ bug.
+ * Makefile.am (sc_tests_stderr_redirection): New check.
+ (sc_tests_stderr_redirection__perl_code): New internal macro.
+ (sc_tests_stderr_redirection__whitelist): Likewise.
+ (syntax_check_rules): Added `sc_tests_stderr_redirection'.
+
2009-12-05 Stefano Lattarini <address@hidden>
Testsuite: avoid Zsh-related problem with `set -x'.
diff --git a/Makefile.am b/Makefile.am
index 0c3f438..cc5769a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -189,6 +189,7 @@ sc_tests_required_after_defs \
sc_tests_overriding_macros_on_cmdline \
sc_tests_plain_sleep \
sc_tests_plain_egrep_fgrep \
+sc_tests_stderr_redirection \
sc_mkdir_p \
sc_perl_at_substs \
sc_unquoted_DESTDIR \
@@ -495,6 +496,71 @@ sc_at_in_texi:
exit 1; \
fi
+## Helper internal macro, holding a list of `file-name:line-number'
+## couples which are exempted from the checks done by target
+## `sc_tests_stderr_redirection' below.
+sc_tests_stderr_redirection__whitelist = \
+ ccnoco.test:37 \
+ depcomp5.test:24
+
+## Helper internal macro, used in the target `sc_tests_stderr_redirection'
+## below. Do NOT use single quotes in the definition of this macro (using
+## them in `##' comments is ok, though, as they get stripped by automake).
+sc_tests_stderr_redirection__perl_code = \
+ use strict; \
+ use warnings FATAL => "all"; \
+ $$^W = 1; \
+ my $$e = 0; \
+ ## List of whitelisted `file-name:line-number' couples, for which
+ ## our tests are to be skipped.
+ my @whitelist = qw!$(sc_tests_stderr_redirection__whitelist)!; \
+ my %whitelist = map { $$_ => 1 } @whitelist; \
+ foreach my $$file (@ARGV) { \
+ open(FILE, "<$$file") or die "$$file: cannot open: $$!\n"; \
+ while (<FILE>) { \
+ ## Remove traling newline from current input line.
+ chomp; \
+ if (exists $$whitelist{"$$file:$$."}) { \
+ ## Current line is whitelisted, checks must be skipped
+ print "$@: INFO: skipping whitelisted line $$file:$$.\n"; \
+ next; \
+ }; \
+ ## Save original input line.
+ my $$s = $$_; \
+ ## Normalize format of redirections.
+ s|(>+)\s*|$$1|g; \
+ ## For our purposes, there is no distinction between overriding
+ ## (`> out') and appending (`>> out') redirections.
+ s|>>|>|g; \
+ ## The construct `>/dev/null 2>&1' still redirects stderr to
+ ## /dev/null, so we can safely ignore it.
+ s|>/dev/null\s+2>&1\b||g; \
+ ## Look for bad stderr redirections, and if any is found,
+ ## display the guilty line (with file name and line number),
+ ## and properly update the exit status.
+ if (m,\b2>(?!/dev/null\b),) { \
+ print "$$file:$$.: $$s\n"; \
+ $$e = 1; \
+ }; \
+ }; \
+ close(FILE) or die "$$file: cannot close: $$!\n"; \
+ }; \
+ exit $$e;
+
+## Redirecting standard error to something != /dev/null might be
+## inappropriate when shell traces are on, due to a bug in Zsh hadling
+## of the xtrace flag.
+sc_tests_stderr_redirection:
+ @cd $(srcdir)/tests || exit 1; \
+ $(PERL) -e '$(sc_tests_stderr_redirection__perl_code)' *.test; \
+ case $$? in \
+ 0) exit 0;; \
+ 1) echo $@: The previous lines might trigger a Zsh xtrace bug.; \
+ echo $@: Consider using the run_command shell function.;; \
+ *) echo $@: INTERNAL ERROR in auxiliary perl script.;; \
+ esac 1>&2; \
+ exit 1;
+
git-dist: maintainer-check
## Make sure the NEWS file is up-to-date.
diff --git a/Makefile.in b/Makefile.in
index d038a5c..8e7c98d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -295,12 +295,45 @@ sc_tests_required_after_defs \
sc_tests_overriding_macros_on_cmdline \
sc_tests_plain_sleep \
sc_tests_plain_egrep_fgrep \
+sc_tests_stderr_redirection \
sc_mkdir_p \
sc_perl_at_substs \
sc_unquoted_DESTDIR \
sc_tabs_in_texi \
sc_at_in_texi
+sc_tests_stderr_redirection__whitelist = \
+ ccnoco.test:37 \
+ depcomp5.test:24
+
+sc_tests_stderr_redirection__perl_code = \
+ use strict; \
+ use warnings FATAL => "all"; \
+ $$^W = 1; \
+ my $$e = 0; \
+ my @whitelist = qw!$(sc_tests_stderr_redirection__whitelist)!; \
+ my %whitelist = map { $$_ => 1 } @whitelist; \
+ foreach my $$file (@ARGV) { \
+ open(FILE, "<$$file") or die "$$file: cannot open: $$!\n"; \
+ while (<FILE>) { \
+ chomp; \
+ if (exists $$whitelist{"$$file:$$."}) { \
+ print "$@: INFO: skipping whitelisted line $$file:$$.\n"; \
+ next; \
+ }; \
+ my $$s = $$_; \
+ s|(>+)\s*|$$1|g; \
+ s|>>|>|g; \
+ s|>/dev/null\s+2>&1\b||g; \
+ if (m,\b2>(?!/dev/null\b),) { \
+ print "$$file:$$.: $$s\n"; \
+ $$e = 1; \
+ }; \
+ }; \
+ close(FILE) or die "$$file: cannot close: $$!\n"; \
+ }; \
+ exit $$e;
+
WGET = wget
WGET_SV_CVS = $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/
WGET_SV_GIT_CF = $(WGET)
'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
@@ -1193,6 +1226,17 @@ sc_at_in_texi:
exit 1; \
fi
+sc_tests_stderr_redirection:
+ @cd $(srcdir)/tests || exit 1; \
+ $(PERL) -e '$(sc_tests_stderr_redirection__perl_code)' *.test; \
+ case $$? in \
+ 0) exit 0;; \
+ 1) echo $@: The previous lines might trigger a Zsh xtrace bug.; \
+ echo $@: Consider using the run_command shell function.;; \
+ *) echo $@: INTERNAL ERROR in auxiliary perl script.;; \
+ esac 1>&2; \
+ exit 1;
+
git-dist: maintainer-check
@if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :;
else \
echo "NEWS not updated; not releasing" 1>&2; \
--
1.6.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 2/3] maintainer-check: warn against zsh xtrace bug,
Stefano Lattarini <=