rebase: add regression tests for console output
Check the console output when using --autostash and the stash applies cleanly 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
b76aeae553867773577f0f88cc495cc978a02f74
1 file changed
+64
-3
t/t3420-rebase-autostash.sh
+64
-3
@@ -33,7 +33,62 @@ test_expect_success setup '
33
git commit -m "related commit"
34
'
35
36
-testrebase() {
36
+create_expected_success_am () {
37
+ cat >expected <<-EOF
38
+ $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
39
+ HEAD is now at $(git rev-parse --short feature-branch) third commit
40
+ First, rewinding head to replay your work on top of it...
41
+ Applying: second commit
42
+ Applying: third commit
43
+ Applied autostash.
44
+ EOF
45
+}
46
+
47
+create_expected_success_interactive () {
48
+ q_to_cr >expected <<-EOF
49
+ $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
50
+ HEAD is now at $(git rev-parse --short feature-branch) third commit
51
+ Rebasing (1/2)QRebasing (2/2)QApplied autostash.
52
+ Successfully rebased and updated refs/heads/rebased-feature-branch.
53
+ EOF
54
+}
55
+
56
+create_expected_success_merge () {
57
+ cat >expected <<-EOF
58
+ $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
59
+ HEAD is now at $(git rev-parse --short feature-branch) third commit
60
+ First, rewinding head to replay your work on top of it...
61
+ Merging unrelated-onto-branch with HEAD~1
62
+ Merging:
63
+ $(git rev-parse --short unrelated-onto-branch) unrelated commit
64
+ $(git rev-parse --short feature-branch^) second commit
65
+ found 1 common ancestor:
66
+ $(git rev-parse --short feature-branch~2) initial commit
67
+ [detached HEAD $(git rev-parse --short rebased-feature-branch~1)] second commit
68
+ Author: A U Thor <author@example.com>
69
+ Date: Thu Apr 7 15:14:13 2005 -0700
70
+ 2 files changed, 2 insertions(+)
71
+ create mode 100644 file1
72
+ create mode 100644 file2
73
+ Committed: 0001 second commit
74
+ Merging unrelated-onto-branch with HEAD~0
75
+ Merging:
76
+ $(git rev-parse --short rebased-feature-branch~1) second commit
77
+ $(git rev-parse --short feature-branch) third commit
78
+ found 1 common ancestor:
79
+ $(git rev-parse --short feature-branch~1) second commit
80
+ [detached HEAD $(git rev-parse --short rebased-feature-branch)] third commit
81
+ Author: A U Thor <author@example.com>
82
+ Date: Thu Apr 7 15:15:13 2005 -0700
83
+ 1 file changed, 1 insertion(+)
84
+ create mode 100644 file3
85
+ Committed: 0002 third commit
86
+ All done.
87
+ Applied autostash.
88
+ EOF
89
+}
90
+
91
+testrebase () {
92
type=$1
93
dotest=$2
94
@@ -51,14 +106,20 @@ testrebase() {
106
test_config rebase.autostash true &&
107
git reset --hard &&
108
git checkout -b rebased-feature-branch feature-branch &&
54
- test_when_finished git branch -D rebased-feature-branch &&
109
echo dirty >>file3 &&
56
- git rebase$type unrelated-onto-branch &&
110
+ git rebase$type unrelated-onto-branch >actual 2>&1 &&
111
grep unrelated file4 &&
112
grep dirty file3 &&
113
git checkout feature-branch
114
'
115
116
+ test_expect_success "rebase$type --autostash: check output" '
117
+ test_when_finished git branch -D rebased-feature-branch &&
118
+ suffix=${type#\ --} && suffix=${suffix:-am} &&
119
+ create_expected_success_$suffix &&
120
+ test_cmp expected actual
121
+ '
122
+
123
test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
124
test_config rebase.autostash true &&
125
git reset --hard &&