bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8893: [PATCH 1/2] tests: make test runner a script, not a shell func


From: Jim Meyering
Subject: bug#8893: [PATCH 1/2] tests: make test runner a script, not a shell function
Date: Sun, 19 Jun 2011 22:26:26 +0200

Stefano Lattarini wrote:
> Subject: [PATCH 2/2] tests: avoid extra forks in the testsuite
>
> * tests/shell-or-perl: Prefer the `read' builtin over `grep' to
> look at the shebang line of test scripts.  Since `read' is a
> special builtin, it might abort the whole program upon failures,
> so add extra sanity checks, verifying that the test script exists
> and is readable, before trying to read from it.
> ---
>  tests/shell-or-perl |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/tests/shell-or-perl b/tests/shell-or-perl
> index ff92009..8c92f87 100644
> --- a/tests/shell-or-perl
> +++ b/tests/shell-or-perl
> @@ -84,12 +84,19 @@ test -z "$test_name" && test_name=$test_script
>  #  Run the test script  #
>  # --------------------- #
>
> -if grep '^#!/usr/bin/perl' "$test_script" >/dev/null; then
> +test -f "$test_script" && test -r "$test_script" \
> +  || error_ "test script '$test_script' does not exist, or isn't readable"
> +
> +read shebang_line < "$test_script" \
> +  || error_ "cannot read from the test script '$test_script'"
> +
> +case $shebang_line in
> +'#!/usr/bin/perl'*)
>    # The test is a perl script.
>    if $cu_PERL -e 'use warnings' > /dev/null 2>&1; then
>      # Perl is available, see if we must run the test with taint
>      # mode on or not.
> -    grep '^#!/usr/bin/perl -T' "$test_script" >/dev/null && T_=T || T_=
> +    case $shebang_line in *\ -T*) T_=T;; *) T_=;; esac
>      # Now run it.
>      exec $cu_PERL -w$T_ -I"$srcdir" -MCoreutils -MCuSkip \
>                    -M"CuTmpdir qw($test_name)" \
> @@ -99,10 +106,11 @@ if grep '^#!/usr/bin/perl' "$test_script" >/dev/null; 
> then
>      echo "$test_name: skip: no usable version of Perl found"
>      exit 77
>    fi
> -else
> +  ;;
> +*)
>    # Assume the test is a shell script.
>    exec $cu_SHELL "$test_script" ${1+"$@"}
> -fi
> +esac

Thank you.  I pushed that as-is.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]