On Sun, May 18, 2014 at 11:59:45PM +0200, Per Cederqvist wrote:
The cmd and shouldfail functions checked the exit status of the
replace_path function instead of the actual command that was running.
(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.
This is a god idea.
The patch still looks good.
Signed-off-by: Josef 'Jeff' Sipek jef...@josefsipek.net
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 ced...@opera.com
---
regression/scaffold | 23 ---
regression/t-032.sh | 2 +-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/regression/scaffold b/regression/scaffold
index 5c8b73e..2e04c83 100644
--- a/regression/scaffold
+++ b/regression/scaffold
@@ -51,19 +51,28 @@ function filter_dd
function cmd
{
echo % $@
- $@ 21 | replace_path return 0
- return 1
+ if ! (
+ exec 31
+ rv=`(($@ 21; echo $? 4) | replace_path 3 ) 41`
+ exit $rv
+ ) ; then
+ echo % FAIL: The above command should succeed but failed.
+ exit 1
+ fi
}
# usage: shouldfail cmd..
function shouldfail
{
echo % $@
- (
- $@ 21 || return 0
- return 1
- ) | replace_path
- return $?
+ if (
+ exec 31
+ rv=`(($@ 21; echo $? 4) | replace_path 3 ) 41`
+ exit $rv
+ ) ; then
+ echo % FAIL: The above command should fail but succeeded.
+ exit 1
+ fi
}
# usage: list_files
diff --git a/regression/t-032.sh b/regression/t-032.sh
index b1d5f19..bba401e 100755
--- a/regression/t-032.sh
+++ b/regression/t-032.sh
@@ -28,7 +28,7 @@ shouldfail guilt import -P foo3 foo
cmd guilt import -P foo2 foo
# ok
-shouldfail guilt import foo
+cmd guilt import foo
# duplicate patch name (implicit)
shouldfail guilt import foo
--
1.8.3.1
--
Intellectuals solve problems; geniuses prevent them
- Albert Einstein
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html