summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20827d9)
raw | patch | inline | side by side (parent: 20827d9)
author | Brandon Casey <casey@nrlssc.navy.mil> | |
Thu, 19 Jun 2008 17:32:02 +0000 (12:32 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 19 Jun 2008 23:07:06 +0000 (16:07 -0700) |
When the arguments to test_must_fail() begin with a variable assignment,
test_must_fail() attempts to execute the variable assignment as a command.
This fails, and so test_must_fail returns with a successful status value
without running the command it was intended to test.
For example, the following script:
#!/bin/sh
test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129
}
foo='wo adrian'
test_must_fail foo='yo adrian' sh -c 'echo foo: $foo'
always exits zero and prints the message:
test.sh: line 3: foo=yo adrian: command not found
Test 16 calls test_must_fail in such a way and therefore has not been
testing whether git 'do[es] not fire editor in the presence of conflicts'.
A workaround is to set and export the variable in a normal way, not
using one-shot notation. Because this would affect the remainder of
the process, the test is done inside a subshell.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
test_must_fail() attempts to execute the variable assignment as a command.
This fails, and so test_must_fail returns with a successful status value
without running the command it was intended to test.
For example, the following script:
#!/bin/sh
test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129
}
foo='wo adrian'
test_must_fail foo='yo adrian' sh -c 'echo foo: $foo'
always exits zero and prints the message:
test.sh: line 3: foo=yo adrian: command not found
Test 16 calls test_must_fail in such a way and therefore has not been
testing whether git 'do[es] not fire editor in the presence of conflicts'.
A workaround is to set and export the variable in a normal way, not
using one-shot notation. Because this would affect the remainder of
the process, the test is done inside a subshell.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7502-commit.sh | patch | blob | history |
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index ed871a6b4d7963f520b994f4d378b02194d69f9e..c25eff9e468acd628cf0a5e7a0968c801396e9f8 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
# Must fail due to conflict
test_must_fail git cherry-pick -n master &&
echo "editor not started" >.git/result &&
- test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
+ (
+ GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" &&
+ export GIT_EDITOR &&
+ test_must_fail git commit
+ ) &&
test "$(cat .git/result)" = "editor not started"
'