tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
Rewrite tests that ran "git" inside command substitution and lost the exit status of "git" so that we notice the failing "git". Have them use modern patterns such as a "test_cmp" of the expected outputs instead. We'll fix more of these these in the subsequent commit, for now we're only converting the cases where this loss of exit code was combined with spawning a sub-shell. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
62f3a45bb4
commit
0cd1a8818d
@ -217,8 +217,12 @@ test_http_push_nonff () {
|
|||||||
git commit -a -m path2 --amend &&
|
git commit -a -m path2 --amend &&
|
||||||
|
|
||||||
test_must_fail git push -v origin >output 2>&1 &&
|
test_must_fail git push -v origin >output 2>&1 &&
|
||||||
(cd "$REMOTE_REPO" &&
|
(
|
||||||
test $HEAD = $(git rev-parse --verify HEAD))
|
cd "$REMOTE_REPO" &&
|
||||||
|
echo "$HEAD" >expect &&
|
||||||
|
git rev-parse --verify HEAD >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'non-fast-forward push show ref status' '
|
test_expect_success 'non-fast-forward push show ref status' '
|
||||||
|
@ -168,20 +168,16 @@ replace_gitfile_with_git_dir () {
|
|||||||
# Note that this only supports submodules at the root level of the
|
# Note that this only supports submodules at the root level of the
|
||||||
# superproject, with the default name, i.e. same as its path.
|
# superproject, with the default name, i.e. same as its path.
|
||||||
test_git_directory_is_unchanged () {
|
test_git_directory_is_unchanged () {
|
||||||
(
|
# does core.worktree point at the right place?
|
||||||
cd ".git/modules/$1" &&
|
echo "../../../$1" >expect &&
|
||||||
# does core.worktree point at the right place?
|
git -C ".git/modules/$1" config core.worktree >actual &&
|
||||||
test "$(git config core.worktree)" = "../../../$1" &&
|
test_cmp expect actual &&
|
||||||
# remove it temporarily before comparing, as
|
# remove it temporarily before comparing, as
|
||||||
# "$1/.git/config" lacks it...
|
# "$1/.git/config" lacks it...
|
||||||
git config --unset core.worktree
|
git -C ".git/modules/$1" config --unset core.worktree &&
|
||||||
) &&
|
|
||||||
diff -r ".git/modules/$1" "$1/.git" &&
|
diff -r ".git/modules/$1" "$1/.git" &&
|
||||||
(
|
# ... and then restore.
|
||||||
# ... and then restore.
|
git -C ".git/modules/$1" config core.worktree "../../../$1"
|
||||||
cd ".git/modules/$1" &&
|
|
||||||
git config core.worktree "../../../$1"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_git_directory_exists () {
|
test_git_directory_exists () {
|
||||||
|
@ -255,7 +255,10 @@ test_expect_success 'prefix_path rejects absolute path to dir with same beginnin
|
|||||||
test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
|
test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
|
||||||
git init repo &&
|
git init repo &&
|
||||||
ln -s repo repolink &&
|
ln -s repo repolink &&
|
||||||
test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")"
|
echo "a" >expect &&
|
||||||
|
repo_path="$(cd repo && pwd)" &&
|
||||||
|
test-tool -C repo path-utils prefix_path prefix "$repo_path/../repolink/a" >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
relative_path /foo/a/b/c/ /foo/a/b/ c/
|
relative_path /foo/a/b/c/ /foo/a/b/ c/
|
||||||
|
@ -245,9 +245,13 @@ test_expect_success 'git branch -M baz bam should succeed within a worktree in w
|
|||||||
(
|
(
|
||||||
cd bazdir &&
|
cd bazdir &&
|
||||||
git branch -M baz bam &&
|
git branch -M baz bam &&
|
||||||
test $(git rev-parse --abbrev-ref HEAD) = bam
|
echo bam >expect &&
|
||||||
|
git rev-parse --abbrev-ref HEAD >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
) &&
|
) &&
|
||||||
test $(git rev-parse --abbrev-ref HEAD) = bam &&
|
echo bam >expect &&
|
||||||
|
git rev-parse --abbrev-ref HEAD >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
rm -r bazdir &&
|
rm -r bazdir &&
|
||||||
git worktree prune
|
git worktree prune
|
||||||
'
|
'
|
||||||
|
@ -15,8 +15,12 @@ test_expect_success 'preparing origin repository' '
|
|||||||
: >file && git add . && git commit -m1 &&
|
: >file && git add . && git commit -m1 &&
|
||||||
git clone --bare . a.git &&
|
git clone --bare . a.git &&
|
||||||
git clone --bare . x &&
|
git clone --bare . x &&
|
||||||
test "$(cd a.git && git config --bool core.bare)" = true &&
|
echo true >expect &&
|
||||||
test "$(cd x && git config --bool core.bare)" = true &&
|
git -C a.git config --bool core.bare >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
echo true >expect &&
|
||||||
|
git -C x config --bool core.bare >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
git bundle create b1.bundle --all &&
|
git bundle create b1.bundle --all &&
|
||||||
git bundle create b2.bundle main &&
|
git bundle create b2.bundle main &&
|
||||||
mkdir dir &&
|
mkdir dir &&
|
||||||
@ -29,7 +33,9 @@ test_expect_success 'preparing origin repository' '
|
|||||||
test_expect_success 'local clone without .git suffix' '
|
test_expect_success 'local clone without .git suffix' '
|
||||||
git clone -l -s a b &&
|
git clone -l -s a b &&
|
||||||
(cd b &&
|
(cd b &&
|
||||||
test "$(git config --bool core.bare)" = false &&
|
echo false >expect &&
|
||||||
|
git config --bool core.bare >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
git fetch)
|
git fetch)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -82,11 +82,19 @@ test_expect_success 'stash with a dirty submodule' '
|
|||||||
CURRENT=$(cd submodule && git rev-parse HEAD) &&
|
CURRENT=$(cd submodule && git rev-parse HEAD) &&
|
||||||
git stash &&
|
git stash &&
|
||||||
test new != $(cat file) &&
|
test new != $(cat file) &&
|
||||||
test submodule = $(git diff --name-only) &&
|
echo submodule >expect &&
|
||||||
test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
|
git diff --name-only >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
echo "$CURRENT" >expect &&
|
||||||
|
git -C submodule rev-parse HEAD >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
git stash apply &&
|
git stash apply &&
|
||||||
test new = $(cat file) &&
|
test new = $(cat file) &&
|
||||||
test $CURRENT = $(cd submodule && git rev-parse HEAD)
|
echo "$CURRENT" >expect &&
|
||||||
|
git -C submodule rev-parse HEAD >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user