From 0bb0c15533c52bfb6f7a5174265869b808faf7ee Mon Sep 17 00:00:00 2001 From: Kacper Kornet Date: Sat, 24 Aug 2013 06:01:44 +0200 Subject: Make test "using invalid commit with -C" more strict In the test 'using invalid commit with -C' git-commit would have failed even if the -C option had been given the correct commit, as there was nothing to commit. Pass --allow-empty to make sure it would make a commit, were there no issues with the argument given to the -C option. Signed-off-by: Kacper Kornet Signed-off-by: Junio C Hamano --- t/t7501-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 99ce36f5ef..f04798f872 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -53,7 +53,7 @@ test_expect_success PERL 'can use paths with --interactive' ' ' test_expect_success 'using invalid commit with -C' ' - test_must_fail git commit -C bogus + test_must_fail git commit --allow-empty -C bogus ' test_expect_success 'nothing to commit' ' -- cgit v1.2.3 From a070221eed679f626fc1cc0e7ea07a1a12ac4626 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 24 Aug 2013 13:13:32 -0700 Subject: add -i test: use skip_all instead of repeated PERL prerequisite It is too easy to forget to add the PERL prerequisite for new "add -i" tests, especially given that many people do not test with NO_PERL so the missing prereq is not always noticed quickly. The test had used the skip_all mechanism since 1b19ccd2 (2009-04-03) but switched to explicit PERL prereqs in f0459319 (2010-10-13) in hope of helping people see how many tests were skipped, perhaps to motivate them to tweak their platform or tests to improve test coverage. That didn't pan out much in practice, so let's move back to the simpler skip_all method. Reported-by: Kacper Kornet Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t3701-add-interactive.sh | 76 +++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 35 deletions(-) (limited to 't') diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 9fab25cc96..9dc91d09d7 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -4,18 +4,24 @@ test_description='add -i basic tests' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh -test_expect_success PERL 'setup (initial)' ' +if ! test_have_prereq PERL +then + skip_all='skipping add -i tests, perl not available' + test_done +fi + +test_expect_success 'setup (initial)' ' echo content >file && git add file && echo more >>file && echo lines >>file ' -test_expect_success PERL 'status works (initial)' ' +test_expect_success 'status works (initial)' ' git add -i output && grep "+1/-0 *+2/-0 file" output ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <output && sed -ne "/new file/,/content/p" diff && test_cmp expected diff ' -test_expect_success PERL 'revert works (initial)' ' +test_expect_success 'revert works (initial)' ' git add file && (echo r; echo 1) | git add -i && git ls-files >output && ! grep . output ' -test_expect_success PERL 'setup (commit)' ' +test_expect_success 'setup (commit)' ' echo baseline >file && git add file && git commit -m commit && @@ -47,12 +53,12 @@ test_expect_success PERL 'setup (commit)' ' echo more >>file && echo lines >>file ' -test_expect_success PERL 'status works (commit)' ' +test_expect_success 'status works (commit)' ' git add -i output && grep "+1/-0 *+2/-0 file" output ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <output && sed -ne "/^index/,/content/p" diff && test_cmp expected diff ' -test_expect_success PERL 'revert works (commit)' ' +test_expect_success 'revert works (commit)' ' git add file && (echo r; echo 1) | git add -i && git add -i output && @@ -76,24 +82,24 @@ test_expect_success PERL 'revert works (commit)' ' ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <fake_editor.sh && chmod a+x fake_editor.sh && test_set_editor "$(pwd)/fake_editor.sh" ' -test_expect_success PERL 'dummy edit works' ' +test_expect_success 'dummy edit works' ' (echo e; echo a) | git add -p && git diff > diff && test_cmp expected diff ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <patch <fake_editor.sh && cat >>fake_editor.sh <<\EOF && mv -f "$1" oldpatch && @@ -113,26 +119,26 @@ EOF test_set_editor "$(pwd)/fake_editor.sh" ' -test_expect_success PERL 'bad edit rejected' ' +test_expect_success 'bad edit rejected' ' git reset && (echo e; echo n; echo d) | git add -p >output && grep "hunk does not apply" output ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <output && grep "hunk does not apply" output ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <patch <expected <output && test_cmp expected output ' -test_expect_success PERL 'skip files similarly as commit -a' ' +test_expect_success 'skip files similarly as commit -a' ' git reset && echo file >.gitignore && echo changed >file && @@ -177,7 +183,7 @@ test_expect_success PERL 'skip files similarly as commit -a' ' ' rm -f .gitignore -test_expect_success PERL,FILEMODE 'patch does not affect mode' ' +test_expect_success FILEMODE 'patch does not affect mode' ' git reset --hard && echo content >>file && chmod +x file && @@ -186,7 +192,7 @@ test_expect_success PERL,FILEMODE 'patch does not affect mode' ' git diff file | grep "new mode" ' -test_expect_success PERL,FILEMODE 'stage mode but not hunk' ' +test_expect_success FILEMODE 'stage mode but not hunk' ' git reset --hard && echo content >>file && chmod +x file && @@ -196,7 +202,7 @@ test_expect_success PERL,FILEMODE 'stage mode but not hunk' ' ' -test_expect_success PERL,FILEMODE 'stage mode and hunk' ' +test_expect_success FILEMODE 'stage mode and hunk' ' git reset --hard && echo content >>file && chmod +x file && @@ -208,14 +214,14 @@ test_expect_success PERL,FILEMODE 'stage mode and hunk' ' # end of tests disabled when filemode is not usable -test_expect_success PERL 'setup again' ' +test_expect_success 'setup again' ' git reset --hard && test_chmod +x file && echo content >>file ' # Write the patch file with a new line at the top and bottom -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <expected <expected <non-empty && git add non-empty && @@ -275,7 +281,7 @@ test_expect_success PERL 'deleting a non-empty file' ' test_cmp expected diff ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected < empty && git add empty && @@ -294,7 +300,7 @@ test_expect_success PERL 'deleting an empty file' ' test_cmp expected diff ' -test_expect_success PERL 'split hunk setup' ' +test_expect_success 'split hunk setup' ' git reset --hard && for i in 10 20 30 40 50 60 do @@ -310,7 +316,7 @@ test_expect_success PERL 'split hunk setup' ' done >test ' -test_expect_success PERL 'split hunk "add -p (edit)"' ' +test_expect_success 'split hunk "add -p (edit)"' ' # Split, say Edit and do nothing. Then: # # 1. Broken version results in a patch that does not apply and -- cgit v1.2.3 From c742f870ce29c145db57d7bc922bc0a4850a32a6 Mon Sep 17 00:00:00 2001 From: Kacper Kornet Date: Sat, 24 Aug 2013 06:01:46 +0200 Subject: t/t7106-reset-unborn-branch.sh: Add PERL prerequisite The test 'reset -p' uses git-reset -p, so it depends on the perl code. Signed-off-by: Kacper Kornet Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t7106-reset-unborn-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index 8062cf502b..499cd88c8f 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -27,7 +27,7 @@ test_expect_success 'reset $file' ' test "$(git ls-files)" = "b" ' -test_expect_success 'reset -p' ' +test_expect_success PERL 'reset -p' ' rm .git/index && git add a && echo y | git reset -p && -- cgit v1.2.3 From 95728f74b100a4feabb5c70c0e6d8bed9dc29451 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 24 Aug 2013 13:34:14 -0700 Subject: reset test: modernize style Avoid command substitution and pipes to ensure that the exit status from each git command is tested (and in particular that any segfaults are caught). Maintain the test setup (no commits, one file named "a", another named "b") even after the last test, to make it easier to rearrange tests or add new tests after the last in the future. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t7106-reset-unborn-branch.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 't') diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index 499cd88c8f..af00ab4d88 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -11,7 +11,10 @@ test_expect_success 'setup' ' test_expect_success 'reset' ' git add a b && git reset && - test "$(git ls-files)" = "" + + >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset HEAD' ' @@ -24,28 +27,42 @@ test_expect_success 'reset $file' ' rm .git/index && git add a b && git reset a && - test "$(git ls-files)" = "b" + + echo b >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success PERL 'reset -p' ' rm .git/index && git add a && - echo y | git reset -p && - test "$(git ls-files)" = "" + echo y >yes && + git reset -p expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset --soft is a no-op' ' rm .git/index && git add a && - git reset --soft - test "$(git ls-files)" = "a" + git reset --soft && + + echo a >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset --hard' ' rm .git/index && git add a && + test_when_finished "echo a >a" && git reset --hard && - test "$(git ls-files)" = "" && + + >expect && + git ls-files >actual && + test_cmp expect actual && test_path_is_missing a ' -- cgit v1.2.3