coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: support stderr verification with returns_()


From: Pádraig Brady
Subject: Re: [PATCH] tests: support stderr verification with returns_()
Date: Mon, 16 Feb 2015 21:23:52 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 16/02/15 21:03, Pádraig Brady wrote:
> * tests/init.sh (returns_): Disable tracing for this wrapper
> function, so that stderr of the wrapped command is unchanged,
> allowing for verification of the contents.
> ---
>  tests/init.sh | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/init.sh b/tests/init.sh
> index ac1e1a2..9f403c5 100755
> --- a/tests/init.sh
> +++ b/tests/init.sh
> @@ -100,10 +100,18 @@ framework_failure_ () { warn_ "$ME_: set-up failure: 
> $@"; Exit 99; }
>  # instead check an explicit exit code like
>  #   returns_ 1 command ... || fail
>  returns_ () {
> +  # Disable tracing so it doesn't interfere with stderr of the wrapped 
> command
> +  { set +x; } 2>/dev/null
> +
>    local exp_exit="$1"
>    shift
>    "$@"
> -  test $? -eq $exp_exit
> +  test $? -eq $exp_exit && ret_=0 || ret_=1
> +
> +  if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then
> +    set -x
> +  fi
> +  { return $ret_; } 2>/dev/null
>  }
>  
>  # Sanitize this shell to POSIX mode, if possible.
> 

I can now also make these adjustments, which were avoided
due to this issue in the original "returns_" patch:

diff --git a/tests/mv/trailing-slash.sh b/tests/mv/trailing-slash.sh
index 47335d3..9fa8df3 100755
--- a/tests/mv/trailing-slash.sh
+++ b/tests/mv/trailing-slash.sh
@@ -55,7 +55,7 @@ printf '%s\n' \
   "cp: cannot create regular file 'no-such/': Not a directory" \
 > expected-err
 touch b
-cp b no-such/ 2> err
+returns_ 1 cp b no-such/ 2>err || fail=1

 # Map "No such file..." diagnostic to the expected "Not a directory"
 sed 's/No such file or directory/Not a directory/' err > k && mv k err
diff --git a/tests/split/fail.sh b/tests/split/fail.sh
index e8f7bc3..5949d68 100755
--- a/tests/split/fail.sh
+++ b/tests/split/fail.sh
@@ -56,7 +56,7 @@ split --number=r/$UINTMAX_MAX/$UINTMAX_MAX </dev/null 
>/dev/null || fail=1
 returns_ 1 split --number=r/$UINTMAX_OFLOW </dev/null 2>/dev/null || fail=1

 # Make sure that a huge obsolete option evokes the right failure.
-split -99999999999999999991 2> out
+returns_ 1 split -99999999999999999991 2> out

 # On losing systems (x86 Solaris 5.9 c89), we get a message like this:
 #   split: line count option -9999999999... is too large




reply via email to

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