rebase: add more regression tests for console output

Check the console output when using --autostash and the stash does not apply is what we expect. The test is quite strict but should catch any changes to the console output from the various rebase flavors. Thanks-to: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Jun 19, 2017 at 18:56 UTC 7d70e6b9029cc033178a73ecedb3f447288b8384
1 file changed +69 -2
t/t3420-rebase-autostash.sh
+69 -2
@@ -88,6 +88,67 @@ create_expected_success_merge () {
88 EOF
89 }
90
91 +create_expected_failure_am () {
92 + cat >expected <<-EOF
93 + $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
94 + HEAD is now at $(git rev-parse --short feature-branch) third commit
95 + First, rewinding head to replay your work on top of it...
96 + Applying: second commit
97 + Applying: third commit
98 + Applying autostash resulted in conflicts.
99 + Your changes are safe in the stash.
100 + You can run "git stash pop" or "git stash drop" at any time.
101 + EOF
102 +}
103 +
104 +create_expected_failure_interactive () {
105 + q_to_cr >expected <<-EOF
106 + $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
107 + HEAD is now at $(git rev-parse --short feature-branch) third commit
108 + Rebasing (1/2)QRebasing (2/2)QApplying autostash resulted in conflicts.
109 + Your changes are safe in the stash.
110 + You can run "git stash pop" or "git stash drop" at any time.
111 + Successfully rebased and updated refs/heads/rebased-feature-branch.
112 + EOF
113 +}
114 +
115 +create_expected_failure_merge () {
116 + cat >expected <<-EOF
117 + $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
118 + HEAD is now at $(git rev-parse --short feature-branch) third commit
119 + First, rewinding head to replay your work on top of it...
120 + Merging unrelated-onto-branch with HEAD~1
121 + Merging:
122 + $(git rev-parse --short unrelated-onto-branch) unrelated commit
123 + $(git rev-parse --short feature-branch^) second commit
124 + found 1 common ancestor:
125 + $(git rev-parse --short feature-branch~2) initial commit
126 + [detached HEAD $(git rev-parse --short rebased-feature-branch~1)] second commit
127 + Author: A U Thor <author@example.com>
128 + Date: Thu Apr 7 15:14:13 2005 -0700
129 + 2 files changed, 2 insertions(+)
130 + create mode 100644 file1
131 + create mode 100644 file2
132 + Committed: 0001 second commit
133 + Merging unrelated-onto-branch with HEAD~0
134 + Merging:
135 + $(git rev-parse --short rebased-feature-branch~1) second commit
136 + $(git rev-parse --short feature-branch) third commit
137 + found 1 common ancestor:
138 + $(git rev-parse --short feature-branch~1) second commit
139 + [detached HEAD $(git rev-parse --short rebased-feature-branch)] third commit
140 + Author: A U Thor <author@example.com>
141 + Date: Thu Apr 7 15:15:13 2005 -0700
142 + 1 file changed, 1 insertion(+)
143 + create mode 100644 file3
144 + Committed: 0002 third commit
145 + All done.
146 + Applying autostash resulted in conflicts.
147 + Your changes are safe in the stash.
148 + You can run "git stash pop" or "git stash drop" at any time.
149 + EOF
150 +}
151 +
152 testrebase () {
153 type=$1
154 dotest=$2
@@ -198,10 +259,9 @@ testrebase () {
259 test_config rebase.autostash true &&
260 git reset --hard &&
261 git checkout -b rebased-feature-branch feature-branch &&
201 - test_when_finished git branch -D rebased-feature-branch &&
262 echo dirty >file4 &&
263 git add file4 &&
204 - git rebase$type unrelated-onto-branch &&
264 + git rebase$type unrelated-onto-branch >actual 2>&1 &&
265 test_path_is_missing $dotest &&
266 git reset --hard &&
267 grep unrelated file4 &&
@@ -210,6 +270,13 @@ testrebase () {
270 git stash pop &&
271 grep dirty file4
272 '
273 +
274 + test_expect_success "rebase$type: check output with conflicting stash" '
275 + test_when_finished git branch -D rebased-feature-branch &&
276 + suffix=${type#\ --} && suffix=${suffix:-am} &&
277 + create_expected_failure_$suffix &&
278 + test_cmp expected actual
279 + '
280 }
281
282 test_expect_success "rebase: fast-forward rebase" '