--- oslo-series-v3/v3-0009-Test-suite-properly-check-the-exit-status-of-comm.patch +++ oslo-series-v4/v4-0009-Test-suite-properly-check-the-exit-status-of-comm.patch @@ -1,7 +1,7 @@ -From 4af978f8edf052d76a5189a222d6d0e5c435d1dc Mon Sep 17 00:00:00 2001 +From f49e38e03400a8a7fe54f3b0571869d8f2042d20 Mon Sep 17 00:00:00 2001 From: Per Cederqvist -Date: Wed, 14 May 2014 22:34:24 +0200 -Subject: [GUILT v3 09/31] Test suite: properly check the exit status of +Date: Sun, 18 May 2014 21:03:00 +0200 +Subject: [GUILT v4 09/33] Test suite: properly check the exit status of commands. To: Jeff Sipek Cc: git@vger.kernel.org @@ -11,13 +11,16 @@ (The $? construct checks the exit status of the last command in a pipeline, not the first command.) +Print an explicit error message if a command that should fail actually +succeeds. + Updated t-032.sh, which used "shouldfail" instead of "cmd" in one place. (The comment in the script makes it clear that the command is expected to succeed.) Signed-off-by: Per Cederqvist --- - regression/scaffold | 17 +++++++++++------ + regression/scaffold | 23 ++++++++++++++++------- regression/t-032.sh | 2 +- - 2 files changed, 12 insertions(+), 7 deletions(-) + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/regression/scaffold b/regression/scaffold index 5c8b73e..e4d7487 100644 --- a/regression/scaffold +++ b/regression/scaffold - @@ -51,18 +51,23 @@ function filter_dd + @@ -51,19 +51,28 @@ function filter_dd function cmd { echo "% $@" - "$@" 2>&1 | replace_path && return 0 - return 1 - + ( + + if ! ( + exec 3>&1 + rv=`(("$@" 2>&1; echo $? >&4) | replace_path >&3 ) 4>&1` + exit $rv - + ) - + return $? + + ) ; then + + echo "% FAIL: The above command should succeed but failed." + + exit 1 + + fi } # usage: shouldfail .. [...] - "$@" 2>&1 || return 0 - return 1 - ) | replace_path - + ! ( + - return $? + + if ( + exec 3>&1 + rv=`(("$@" 2>&1; echo $? >&4) | replace_path >&3 ) 4>&1` + exit $rv - + ) - return $? + + ) ; then + + echo "% FAIL: The above command should fail but succeeded." + + exit 1 + + fi } + # usage: list_files