Skip to content

Commit

Permalink
lib-patch-mode tests: change from skip_all=* to prereq skip
Browse files Browse the repository at this point in the history
Change this test to skip test with test prerequisites, and to do setup
work in tests. This improves the skipped statistics on platforms where
the test isn't run.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
avar authored and gitster committed Aug 18, 2010
1 parent f045931 commit f2f7b6a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
5 changes: 0 additions & 5 deletions t/lib-patch-mode.sh
Expand Up @@ -2,11 +2,6 @@


. ./test-lib.sh . ./test-lib.sh


if ! test_have_prereq PERL; then
skip_all='skipping --patch tests, perl not available'
test_done
fi

set_state () { set_state () {
echo "$3" > "$1" && echo "$3" > "$1" &&
git add "$1" && git add "$1" &&
Expand Down
28 changes: 14 additions & 14 deletions t/t2016-checkout-patch.sh
Expand Up @@ -4,7 +4,7 @@ test_description='git checkout --patch'


. ./lib-patch-mode.sh . ./lib-patch-mode.sh


test_expect_success 'setup' ' test_expect_success PERL 'setup' '
mkdir dir && mkdir dir &&
echo parent > dir/foo && echo parent > dir/foo &&
echo dummy > bar && echo dummy > bar &&
Expand All @@ -18,55 +18,55 @@ test_expect_success 'setup' '


# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar' # note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'


test_expect_success 'saying "n" does nothing' ' test_expect_success PERL 'saying "n" does nothing' '
set_and_save_state dir/foo work head && set_and_save_state dir/foo work head &&
(echo n; echo n) | git checkout -p && (echo n; echo n) | git checkout -p &&
verify_saved_state bar && verify_saved_state bar &&
verify_saved_state dir/foo verify_saved_state dir/foo
' '


test_expect_success 'git checkout -p' ' test_expect_success PERL 'git checkout -p' '
(echo n; echo y) | git checkout -p && (echo n; echo y) | git checkout -p &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'git checkout -p with staged changes' ' test_expect_success PERL 'git checkout -p with staged changes' '
set_state dir/foo work index set_state dir/foo work index
(echo n; echo y) | git checkout -p && (echo n; echo y) | git checkout -p &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo index index verify_state dir/foo index index
' '


test_expect_success 'git checkout -p HEAD with NO staged changes: abort' ' test_expect_success PERL 'git checkout -p HEAD with NO staged changes: abort' '
set_and_save_state dir/foo work head && set_and_save_state dir/foo work head &&
(echo n; echo y; echo n) | git checkout -p HEAD && (echo n; echo y; echo n) | git checkout -p HEAD &&
verify_saved_state bar && verify_saved_state bar &&
verify_saved_state dir/foo verify_saved_state dir/foo
' '


test_expect_success 'git checkout -p HEAD with NO staged changes: apply' ' test_expect_success PERL 'git checkout -p HEAD with NO staged changes: apply' '
(echo n; echo y; echo y) | git checkout -p HEAD && (echo n; echo y; echo y) | git checkout -p HEAD &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'git checkout -p HEAD with change already staged' ' test_expect_success PERL 'git checkout -p HEAD with change already staged' '
set_state dir/foo index index set_state dir/foo index index
# the third n is to get out in case it mistakenly does not apply # the third n is to get out in case it mistakenly does not apply
(echo n; echo y; echo n) | git checkout -p HEAD && (echo n; echo y; echo n) | git checkout -p HEAD &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'git checkout -p HEAD^' ' test_expect_success PERL 'git checkout -p HEAD^' '
# the third n is to get out in case it mistakenly does not apply # the third n is to get out in case it mistakenly does not apply
(echo n; echo y; echo n) | git checkout -p HEAD^ && (echo n; echo y; echo n) | git checkout -p HEAD^ &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo parent parent verify_state dir/foo parent parent
' '


test_expect_success 'git checkout -p handles deletion' ' test_expect_success PERL 'git checkout -p handles deletion' '
set_state dir/foo work index && set_state dir/foo work index &&
rm dir/foo && rm dir/foo &&
(echo n; echo y) | git checkout -p && (echo n; echo y) | git checkout -p &&
Expand All @@ -79,36 +79,36 @@ test_expect_success 'git checkout -p handles deletion' '
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in # dir/foo. There's always an extra 'n' to reject edits to dir/foo in
# the failure case (and thus get out of the loop). # the failure case (and thus get out of the loop).


test_expect_success 'path limiting works: dir' ' test_expect_success PERL 'path limiting works: dir' '
set_state dir/foo work head && set_state dir/foo work head &&
(echo y; echo n) | git checkout -p dir && (echo y; echo n) | git checkout -p dir &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'path limiting works: -- dir' ' test_expect_success PERL 'path limiting works: -- dir' '
set_state dir/foo work head && set_state dir/foo work head &&
(echo y; echo n) | git checkout -p -- dir && (echo y; echo n) | git checkout -p -- dir &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'path limiting works: HEAD^ -- dir' ' test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
# the third n is to get out in case it mistakenly does not apply # the third n is to get out in case it mistakenly does not apply
(echo y; echo n; echo n) | git checkout -p HEAD^ -- dir && (echo y; echo n; echo n) | git checkout -p HEAD^ -- dir &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo parent parent verify_state dir/foo parent parent
' '


test_expect_success 'path limiting works: foo inside dir' ' test_expect_success PERL 'path limiting works: foo inside dir' '
set_state dir/foo work head && set_state dir/foo work head &&
# the third n is to get out in case it mistakenly does not apply # the third n is to get out in case it mistakenly does not apply
(echo y; echo n; echo n) | (cd dir && git checkout -p foo) && (echo y; echo n; echo n) | (cd dir && git checkout -p foo) &&
verify_saved_state bar && verify_saved_state bar &&
verify_state dir/foo head head verify_state dir/foo head head
' '


test_expect_success 'none of this moved HEAD' ' test_expect_success PERL 'none of this moved HEAD' '
verify_saved_head verify_saved_head
' '


Expand Down
10 changes: 5 additions & 5 deletions t/t3904-stash-patch.sh
Expand Up @@ -3,7 +3,7 @@
test_description='git checkout --patch' test_description='git checkout --patch'
. ./lib-patch-mode.sh . ./lib-patch-mode.sh


test_expect_success 'setup' ' test_expect_success PERL 'setup' '
mkdir dir && mkdir dir &&
echo parent > dir/foo && echo parent > dir/foo &&
echo dummy > bar && echo dummy > bar &&
Expand All @@ -19,14 +19,14 @@ test_expect_success 'setup' '


# note: bar sorts before dir, so the first 'n' is always to skip 'bar' # note: bar sorts before dir, so the first 'n' is always to skip 'bar'


test_expect_success 'saying "n" does nothing' ' test_expect_success PERL 'saying "n" does nothing' '
set_state dir/foo work index set_state dir/foo work index
(echo n; echo n) | test_must_fail git stash save -p && (echo n; echo n) | test_must_fail git stash save -p &&
verify_state dir/foo work index && verify_state dir/foo work index &&
verify_saved_state bar verify_saved_state bar
' '


test_expect_success 'git stash -p' ' test_expect_success PERL 'git stash -p' '
(echo n; echo y) | git stash save -p && (echo n; echo y) | git stash save -p &&
verify_state dir/foo head index && verify_state dir/foo head index &&
verify_saved_state bar && verify_saved_state bar &&
Expand All @@ -36,7 +36,7 @@ test_expect_success 'git stash -p' '
verify_state bar dummy dummy verify_state bar dummy dummy
' '


test_expect_success 'git stash -p --no-keep-index' ' test_expect_success PERL 'git stash -p --no-keep-index' '
set_state dir/foo work index && set_state dir/foo work index &&
set_state bar bar_work bar_index && set_state bar bar_work bar_index &&
(echo n; echo y) | git stash save -p --no-keep-index && (echo n; echo y) | git stash save -p --no-keep-index &&
Expand All @@ -48,7 +48,7 @@ test_expect_success 'git stash -p --no-keep-index' '
verify_state bar dummy bar_index verify_state bar dummy bar_index
' '


test_expect_success 'none of this moved HEAD' ' test_expect_success PERL 'none of this moved HEAD' '
verify_saved_head verify_saved_head
' '


Expand Down
8 changes: 4 additions & 4 deletions t/t7105-reset-patch.sh
Expand Up @@ -41,27 +41,27 @@ test_expect_success 'git reset -p HEAD^' '
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in # dir/foo. There's always an extra 'n' to reject edits to dir/foo in
# the failure case (and thus get out of the loop). # the failure case (and thus get out of the loop).


test_expect_success 'git reset -p dir' ' test_expect_success PERL 'git reset -p dir' '
set_state dir/foo work work set_state dir/foo work work
(echo y; echo n) | git reset -p dir && (echo y; echo n) | git reset -p dir &&
verify_state dir/foo work head && verify_state dir/foo work head &&
verify_saved_state bar verify_saved_state bar
' '


test_expect_success 'git reset -p -- foo (inside dir)' ' test_expect_success PERL 'git reset -p -- foo (inside dir)' '
set_state dir/foo work work set_state dir/foo work work
(echo y; echo n) | (cd dir && git reset -p -- foo) && (echo y; echo n) | (cd dir && git reset -p -- foo) &&
verify_state dir/foo work head && verify_state dir/foo work head &&
verify_saved_state bar verify_saved_state bar
' '


test_expect_success 'git reset -p HEAD^ -- dir' ' test_expect_success PERL 'git reset -p HEAD^ -- dir' '
(echo y; echo n) | git reset -p HEAD^ -- dir && (echo y; echo n) | git reset -p HEAD^ -- dir &&
verify_state dir/foo work parent && verify_state dir/foo work parent &&
verify_saved_state bar verify_saved_state bar
' '


test_expect_success 'none of this moved HEAD' ' test_expect_success PERL 'none of this moved HEAD' '
verify_saved_head verify_saved_head
' '


Expand Down

0 comments on commit f2f7b6a

Please sign in to comment.