test: test cherry-pick functionality and output separately

Since v1.7.3-rc0~26^2~9 (revert: report success when using option --strategy, 2010-07-14), the cherry-pick-many-commits test checks the format of output written to the terminal during a cherry-pick sequence in addition to the functionality. There is no reason those have to be checked in the same test, though, and it has some downsides: - when progress output is broken, the test result does not convey whether the functionality was also broken or not - it is not immediately obvious when reading that these checks are meant to prevent regressions in details of the output format and are not just a roundabout way to check functional details like the number of commits produced - there is a temptation to include the same kind of output checking for every new cherry-pick test, which would make future changes to the output unnecessarily difficult Put the tests from v1.7.3-rc0~26^2~9 in separate assertions, following the principle "test one feature at a time". Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Mar 13, 2012 at 00:00 UTC 2593633f5a7e1ddc02cd5f8256d02a53324e4cf6
1 file changed +22 -8
t/t3508-cherry-pick-many-commits.sh
+22 -8
@@ -35,6 +35,16 @@ test_expect_success setup '
35 '
36
37 test_expect_success 'cherry-pick first..fourth works' '
38 + git checkout -f master &&
39 + git reset --hard first &&
40 + test_tick &&
41 + git cherry-pick first..fourth &&
42 + git diff --quiet other &&
43 + git diff --quiet HEAD other &&
44 + check_head_differs_from fourth
45 +'
46 +
47 +test_expect_success 'output to keep user entertained during multi-pick' '
48 cat <<-\EOF >expected &&
49 [master OBJID] second
50 Author: A U Thor <author@example.com>
@@ -51,15 +61,22 @@ test_expect_success 'cherry-pick first..fourth works' '
61 git reset --hard first &&
62 test_tick &&
63 git cherry-pick first..fourth >actual &&
64 + sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
65 + test_line_count -ge 3 actual.fuzzy &&
66 + test_i18ncmp expected actual.fuzzy
67 +'
68 +
69 +test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
70 + git checkout -f master &&
71 + git reset --hard first &&
72 + test_tick &&
73 + git cherry-pick --strategy resolve first..fourth &&
74 git diff --quiet other &&
75 git diff --quiet HEAD other &&
56 -
57 - sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
58 - test_i18ncmp expected actual.fuzzy &&
76 check_head_differs_from fourth
77 '
78
62 -test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
79 +test_expect_success 'output during multi-pick indicates merge strategy' '
80 cat <<-\EOF >expected &&
81 Trying simple merge.
82 [master OBJID] second
@@ -79,11 +96,8 @@ test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
96 git reset --hard first &&
97 test_tick &&
98 git cherry-pick --strategy resolve first..fourth >actual &&
82 - git diff --quiet other &&
83 - git diff --quiet HEAD other &&
99 sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
85 - test_i18ncmp expected actual.fuzzy &&
86 - check_head_differs_from fourth
100 + test_i18ncmp expected actual.fuzzy
101 '
102
103 test_expect_success 'cherry-pick --ff first..fourth works' '