diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-07-13 23:50:15 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-07-21 14:00:03 +0100 |
commit | 0ac06406dcc6cf9c5f1fbeef340764e73cc8eae0 (patch) | |
tree | cc655eed63fd2d3892d7c3d485f50c6435bcee31 | |
parent | 958a8a47cfc18faaf86a8be9eec3dd8589ffd2bd (diff) | |
download | automake-0ac06406dcc6cf9c5f1fbeef340764e73cc8eae0.tar.gz automake-0ac06406dcc6cf9c5f1fbeef340764e73cc8eae0.tar.bz2 automake-0ac06406dcc6cf9c5f1fbeef340764e73cc8eae0.zip |
test harness: improve catching of usage errors in script 'test-driver'
Fixes automake bug#14840.
* lib/test-driver: Catch and report usage errors where the caller has
forgotten to specify one of the mandatory options (--test-name,
--log-file, --trs-file) or has not passed any non-option argument.
Also, be sure to work correctly even when no '--' special argument
is passed to separate option from non-options arguments.
* THANKS: Update.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r-- | THANKS | 1 | ||||
-rwxr-xr-x | lib/test-driver | 20 |
2 files changed, 17 insertions, 4 deletions
@@ -405,6 +405,7 @@ Ulrich Drepper drepper@gnu.ai.mit.edu Ulrich Eckhardt eckhardt@satorlaser.com Václav Haisman V.Haisman@sh.cvut.cz Vadim Zeitlin Vadim.zeitlin@dptmaths.ens-cachan.fr +Vasyl Khalak basiliomail@gmail.com Vincent Lefevre vincent@vinc17.org Vladimir Serbinenko phcoder@gmail.com Volker Boerchers vboerchers@tecon.de diff --git a/lib/test-driver b/lib/test-driver index 32bf39e83..d30605660 100755 --- a/lib/test-driver +++ b/lib/test-driver @@ -1,7 +1,7 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2012-06-27.10; # UTC +scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2013 Free Software Foundation, Inc. # @@ -44,13 +44,12 @@ print_usage () Usage: test-driver --test-name=NAME --log-file=PATH --trs-file=PATH [--expect-failure={yes|no}] [--color-tests={yes|no}] - [--enable-hard-errors={yes|no}] [--] TEST-SCRIPT + [--enable-hard-errors={yes|no}] [--] + TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] The '--test-name', '--log-file' and '--trs-file' options are mandatory. END } -# TODO: better error handling in option parsing (in particular, ensure -# TODO: $log_file, $trs_file and $test_name are defined). test_name= # Used for reporting. log_file= # Where to save the output of the test script. trs_file= # Where to save the metadata of the test run. @@ -69,10 +68,23 @@ while test $# -gt 0; do --enable-hard-errors) enable_hard_errors=$2; shift;; --) shift; break;; -*) usage_error "invalid option: '$1'";; + *) break;; esac shift done +missing_opts= +test x"$test_name" = x && missing_opts="$missing_opts --test-name" +test x"$log_file" = x && missing_opts="$missing_opts --log-file" +test x"$trs_file" = x && missing_opts="$missing_opts --trs-file" +if test x"$missing_opts" != x; then + usage_error "the following mandatory options are missing:$missing_opts" +fi + +if test $# -eq 0; then + usage_error "missing argument" +fi + if test $color_tests = yes; then # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. red='[0;31m' # Red. |