1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-08 18:16:09 +02:00
git/t/t7060-wtstatus.sh
Ævar Arnfjörð Bjarmason 3e3b9321ca leak tests: mark passing SANITIZE=leak tests as leak-free
Mark those remaining tests that pass when run under SANITIZE=leak with
TEST_PASSES_SANITIZE_LEAK=true, these were either omitted in
f346fcb62a (Merge branch 'ab/mark-leak-free-tests-even-more',
2021-12-15) and 5a4f8381b6 (Merge branch 'ab/mark-leak-free-tests',
2021-10-25), or have had their memory leaks fixed since then.

With this change there's now a a one-to-one mapping between those
tests that we have opted-in via "TEST_PASSES_SANITIZE_LEAK=true", and
those that pass with the new "check" mode:

	GIT_TEST_PASSING_SANITIZE_LEAK=check \
	GIT_TEST_SANITIZE_LEAK_LOG=true \
	make test SANITIZE=leak

Note that the "GIT_TEST_SANITIZE_LEAK_LOG=true" is needed due to the
edge cases noted in a preceding commit, i.e. in some cases we'd pass
the test itself, but still have outstanding leaks due to ignored exit
codes.

The "GIT_TEST_SANITIZE_LEAK_LOG=true" corrects for that, we're only
marking those tests as passing that really don't have any leaks,
whether that was reflected in their exit code or not.

Note that the change here to "t9100-git-svn-basic.sh" is marking that
test as passing under SANITIZE=leak, we're removing a
"TEST_FAILS_SANITIZE_LEAK=true" line, not
"TEST_PASSES_SANITIZE_LEAK=true". See 7a98d9ab00 (revisions API: have
release_revisions() release "cmdline", 2022-04-13) for the
introduction of that t/lib-git-svn.sh-specific variable.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-27 16:35:40 -07:00

256 lines
6.1 KiB
Bash
Executable File

#!/bin/sh
test_description='basic work tree status reporting'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '
git config --global advice.statusuoption false &&
test_commit A &&
test_commit B oneside added &&
git checkout A^0 &&
test_commit C oneside created
'
test_expect_success 'A/A conflict' '
git checkout B^0 &&
test_must_fail git merge C
'
test_expect_success 'Report path with conflict' '
git diff --cached --name-status >actual &&
echo "U oneside" >expect &&
test_cmp expect actual
'
test_expect_success 'Report new path with conflict' '
git diff --cached --name-status HEAD^ >actual &&
echo "U oneside" >expect &&
test_cmp expect actual
'
test_expect_success 'M/D conflict does not segfault' '
cat >expect <<EOF &&
On branch side
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: foo
no changes added to commit (use "git add" and/or "git commit -a")
EOF
mkdir mdconflict &&
(
cd mdconflict &&
git init &&
test_commit initial foo "" &&
test_commit modify foo foo &&
git checkout -b side HEAD^ &&
git rm foo &&
git commit -m delete &&
test_must_fail git merge main &&
test_must_fail git commit --dry-run >../actual &&
test_cmp ../expect ../actual &&
git status >../actual &&
test_cmp ../expect ../actual
)
'
test_expect_success 'rename & unmerged setup' '
git rm -f -r . &&
cat "$TEST_DIRECTORY/README" >ONE &&
git add ONE &&
test_tick &&
git commit -m "One commit with ONE" &&
echo Modified >TWO &&
cat ONE >>TWO &&
cat ONE >>THREE &&
git add TWO THREE &&
sha1=$(git rev-parse :ONE) &&
git rm --cached ONE &&
(
echo "100644 $sha1 1 ONE" &&
echo "100644 $sha1 2 ONE" &&
echo "100644 $sha1 3 ONE"
) | git update-index --index-info &&
echo Further >>THREE
'
test_expect_success 'rename & unmerged status' '
git status -suno >actual &&
cat >expect <<-EOF &&
UU ONE
AM THREE
A TWO
EOF
test_cmp expect actual
'
test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
cat >expected <<-EOF &&
U ONE
A THREE
A TWO
EOF
git diff-index --cached --name-status HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
cat >expected <<-EOF &&
U ONE
A THREE
A TWO
EOF
git diff-index --cached -M --name-status HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
cat >expected <<-EOF &&
U ONE
C ONE THREE
C ONE TWO
EOF
git diff-index --cached -C --name-status HEAD |
sed "s/^C[0-9]*/C/g" >actual &&
test_cmp expected actual
'
test_expect_success 'status when conflicts with add and rm advice (deleted by them)' '
git reset --hard &&
git checkout main &&
test_commit init main.txt init &&
git checkout -b second_branch &&
git rm main.txt &&
git commit -m "main.txt deleted on second_branch" &&
test_commit second conflict.txt second &&
git checkout main &&
test_commit on_second main.txt on_second &&
test_commit main conflict.txt main &&
test_must_fail git merge second_branch &&
cat >expected <<\EOF &&
On branch main
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
both added: conflict.txt
deleted by them: main.txt
no changes added to commit (use "git add" and/or "git commit -a")
EOF
git status --untracked-files=no >actual &&
test_cmp expected actual
'
test_expect_success 'prepare for conflicts' '
git reset --hard &&
git checkout -b conflict &&
test_commit one main.txt one &&
git branch conflict_second &&
git mv main.txt sub_main.txt &&
git commit -m "main.txt renamed in sub_main.txt" &&
git checkout conflict_second &&
git mv main.txt sub_second.txt &&
git commit -m "main.txt renamed in sub_second.txt"
'
test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
test_must_fail git merge conflict &&
cat >expected <<\EOF &&
On branch conflict_second
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
both deleted: main.txt
added by them: sub_main.txt
added by us: sub_second.txt
no changes added to commit (use "git add" and/or "git commit -a")
EOF
git status --untracked-files=no >actual &&
test_cmp expected actual
'
test_expect_success 'status when conflicts with only rm advice (both deleted)' '
git reset --hard conflict_second &&
test_must_fail git merge conflict &&
git add sub_main.txt &&
git add sub_second.txt &&
cat >expected <<\EOF &&
On branch conflict_second
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
new file: sub_main.txt
Unmerged paths:
(use "git rm <file>..." to mark resolution)
both deleted: main.txt
Untracked files not listed (use -u option to show untracked files)
EOF
git status --untracked-files=no >actual &&
test_cmp expected actual &&
git reset --hard &&
git checkout main
'
test_expect_success 'status --branch with detached HEAD' '
git reset --hard &&
git checkout main^0 &&
git status --branch --porcelain >actual &&
cat >expected <<-EOF &&
## HEAD (no branch)
?? .gitconfig
?? actual
?? expect
?? expected
?? mdconflict/
EOF
test_cmp expected actual
'
## Duplicate the above test and verify --porcelain=v1 arg parsing.
test_expect_success 'status --porcelain=v1 --branch with detached HEAD' '
git reset --hard &&
git checkout main^0 &&
git status --branch --porcelain=v1 >actual &&
cat >expected <<-EOF &&
## HEAD (no branch)
?? .gitconfig
?? actual
?? expect
?? expected
?? mdconflict/
EOF
test_cmp expected actual
'
## Verify parser error on invalid --porcelain argument.
test_expect_success 'status --porcelain=bogus' '
test_must_fail git status --porcelain=bogus
'
test_done