diff options
author | Jim Meyering <meyering@redhat.com> | 2011-06-21 09:04:59 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-06-21 09:04:59 +0200 |
commit | 10d393b5f55472834b2f4b2c6f68acfdb4a97f2d (patch) | |
tree | fe853c56a3eb157c03841989d84a92121b2e0667 | |
parent | 8f09073c88002f4bf1d83331d6cff03a04a3b9b6 (diff) | |
download | grep-10d393b5f55472834b2f4b2c6f68acfdb4a97f2d.tar.gz |
tests: update init.sh; simplify TESTS_ENVIRONMENT
* tests/init.sh: Update from coreutils.
* tests/Makefile.am (TESTS_ENVIRONMENT): Remove shell_or_perl_
function. Instead, just use $(SHELL), since grep has no test
that starts with #!/usr/bin/perl.
-rw-r--r-- | tests/Makefile.am | 17 | ||||
-rw-r--r-- | tests/init.sh | 27 |
2 files changed, 23 insertions, 21 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f0d2cfe..6829d303 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -104,21 +104,6 @@ MALLOC_PERTURB_ = 1 TESTS_ENVIRONMENT = \ tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \ TMPDIR=$$tmp__; export TMPDIR; \ - shell_or_perl_() { \ - if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \ - if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \ - grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \ - $(PERL) -w$$T_ -I$(srcdir) -MCoreutils \ - -M"CuTmpdir qw($$f)" -- "$$1"; \ - else \ - echo 1>&2 "$$tst: configure did not find a usable version of Perl," \ - "so skipping this test"; \ - (exit 77); \ - fi; \ - else \ - $(SHELL) "$$1"; \ - fi; \ - }; \ export \ VERSION='$(VERSION)' \ LOCALE_FR='$(LOCALE_FR)' \ @@ -141,6 +126,6 @@ TESTS_ENVIRONMENT = \ PERL='$(PERL)' \ SHELL='$(SHELL)' \ PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \ - ; shell_or_perl_ 9>&2 + ; $(SHELL) 9>&2 VERBOSE = yes diff --git a/tests/init.sh b/tests/init.sh index 71c65169..460937de 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -68,15 +68,29 @@ Exit () { set +e; (exit $1); exit $1; } # Print warnings (e.g., about skipped and failed tests) to this file number. # Override by defining to say, 9, in init.cfg, and putting say, -# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition -# of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# export ...ENVVAR_SETTINGS...; $(SHELL) 9>&2 +# in the definition of TESTS_ENVIRONMENT in your tests/Makefile.am file. # This is useful when using automake's parallel tests mode, to print # the reason for skip/failure to console, rather than to the .log files. : ${stderr_fileno_=2} -warn_ () { echo "$@" 1>&$stderr_fileno_; } +# Note that correct expansion of "$*" depends on IFS starting with ' '. +# Always write the full diagnostic to stderr. +# When stderr_fileno_ is not 2, also emit the first line of the +# diagnostic to that file descriptor. +warn_ () +{ + # If IFS does not start with ' ', set it and emit the warning in a subshell. + case $IFS in + ' '*) printf '%s\n' "$*" >&2 + test $stderr_fileno_ = 2 \ + || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;; + *) (IFS=' '; warn_ "$@");; + esac +} fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; } skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } +fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } # Sanitize this shell to POSIX mode, if possible. @@ -167,7 +181,10 @@ else st_=$? # $re_shell_ works just fine. Use it. - test $st_ = 10 && break + if test $st_ = 10; then + gl_set_x_corrupts_stderr_=false + break + fi # If this is our first marginally acceptable shell, remember it. if test "$st_:$marginal_" = 9: ; then @@ -400,7 +417,7 @@ mktempd_ () { case $# in 2);; - *) fail_ "Usage: $ME DIR TEMPLATE";; + *) fail_ "Usage: mktempd_ DIR TEMPLATE";; esac destdir_=$1 |