t6200 (fmt-merge-msg): style nitpicks
Guard setup with test_expect_success. Use test_might_fail instead of ignoring the exit code from git config --unset. Point out setup commands that are shared by multiple tests, to make it easy to write GIT_SKIP_TESTS specifications that work. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Aug 17, 2010 at 01:57 UTC
d834c96a0eba93de78aa8252f6fcca39d18343d5
1 file changed
+120
-160
t/t6200-fmt-merge-msg.sh
+120
-160
@@ -70,14 +70,13 @@ test_expect_success setup '
70
i=$(($i+1))
71
done &&
72
73
- git show-branch
74
-'
73
+ git show-branch &&
74
76
-cat >expected <<\EOF
77
-Merge branch 'left'
78
-EOF
75
+ apos="'\''"
76
+'
77
80
-test_expect_success 'merge-msg test #1' '
78
+test_expect_success 'message for merging local branch' '
79
+ echo "Merge branch ${apos}left${apos}" >expected &&
80
81
git checkout master &&
82
git fetch . left &&
@@ -86,11 +85,8 @@ test_expect_success 'merge-msg test #1' '
85
test_cmp expected actual
86
'
87
89
-cat >expected <<EOF
90
-Merge branch 'left' of $(pwd)
91
-EOF
92
-
93
-test_expect_success 'merge-msg test #2' '
88
+test_expect_success 'message for merging external branch' '
89
+ echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
90
91
git checkout master &&
92
git fetch "$(pwd)" left &&
@@ -99,139 +95,108 @@ test_expect_success 'merge-msg test #2' '
95
test_cmp expected actual
96
'
97
102
-cat >expected <<\EOF
103
-Merge branch 'left'
104
-
105
-* left:
106
- Left #5
107
- Left #4
108
- Left #3
109
- Common #2
110
- Common #1
111
-EOF
98
+test_expect_success '[merge] summary/log configuration' '
99
+ cat >expected <<-EOF &&
100
+ Merge branch ${apos}left${apos}
101
113
-test_expect_success 'merge-msg test #3-1' '
102
+ * left:
103
+ Left #5
104
+ Left #4
105
+ Left #3
106
+ Common #2
107
+ Common #1
108
+ EOF
109
115
- git config --unset-all merge.log
116
- git config --unset-all merge.summary
110
git config merge.log true &&
111
+ test_might_fail git config --unset-all merge.summary &&
112
113
git checkout master &&
114
test_tick &&
115
git fetch . left &&
116
123
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
124
- test_cmp expected actual
125
-'
126
-
127
-test_expect_success 'merge-msg test #3-2' '
117
+ git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
118
129
- git config --unset-all merge.log
130
- git config --unset-all merge.summary
119
+ test_might_fail git config --unset-all merge.log &&
120
git config merge.summary true &&
121
122
git checkout master &&
123
test_tick &&
124
git fetch . left &&
125
137
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
138
- test_cmp expected actual
139
-'
140
-
141
-cat >expected <<\EOF
142
-Merge branches 'left' and 'right'
126
+ git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
127
144
-* left:
145
- Left #5
146
- Left #4
147
- Left #3
148
- Common #2
149
- Common #1
150
-
151
-* right:
152
- Right #5
153
- Right #4
154
- Right #3
155
- Common #2
156
- Common #1
157
-EOF
128
+ test_cmp expected actual1 &&
129
+ test_cmp expected actual2
130
+'
131
159
-test_expect_success 'merge-msg test #4-1' '
132
+test_expect_success 'setup: expected shortlog for two branches' '
133
+ cat >expected <<-EOF
134
+ Merge branches ${apos}left${apos} and ${apos}right${apos}
135
+
136
+ * left:
137
+ Left #5
138
+ Left #4
139
+ Left #3
140
+ Common #2
141
+ Common #1
142
+
143
+ * right:
144
+ Right #5
145
+ Right #4
146
+ Right #3
147
+ Common #2
148
+ Common #1
149
+ EOF
150
+'
151
161
- git config --unset-all merge.log
162
- git config --unset-all merge.summary
152
+test_expect_success 'shortlog for two branches' '
153
git config merge.log true &&
164
-
154
+ test_might_fail git config --unset-all merge.summary &&
155
git checkout master &&
156
test_tick &&
157
git fetch . left right &&
158
+ git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
159
169
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
170
- test_cmp expected actual
171
-'
172
-
173
-test_expect_success 'merge-msg test #4-2' '
174
-
175
- git config --unset-all merge.log
176
- git config --unset-all merge.summary
160
+ test_might_fail git config --unset-all merge.log &&
161
git config merge.summary true &&
178
-
162
git checkout master &&
163
test_tick &&
164
git fetch . left right &&
165
+ git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
166
183
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
184
- test_cmp expected actual
185
-'
186
-
187
-test_expect_success 'merge-msg test #5-1' '
188
-
189
- git config --unset-all merge.log
190
- git config --unset-all merge.summary
167
git config merge.log yes &&
192
-
168
+ test_might_fail git config --unset-all merge.summary &&
169
git checkout master &&
170
test_tick &&
171
git fetch . left right &&
172
+ git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
173
197
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
198
- test_cmp expected actual
199
-'
200
-
201
-test_expect_success 'merge-msg test #5-2' '
202
-
203
- git config --unset-all merge.log
204
- git config --unset-all merge.summary
174
+ test_might_fail git config --unset-all merge.log &&
175
git config merge.summary yes &&
206
-
176
git checkout master &&
177
test_tick &&
178
git fetch . left right &&
179
+ git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
180
211
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
212
- test_cmp expected actual
181
+ test_cmp expected actual1 &&
182
+ test_cmp expected actual2 &&
183
+ test_cmp expected actual3 &&
184
+ test_cmp expected actual4
185
'
186
187
test_expect_success 'merge-msg -F' '
216
-
217
- git config --unset-all merge.log
218
- git config --unset-all merge.summary
188
+ test_might_fail git config --unset-all merge.log &&
189
git config merge.summary yes &&
220
-
190
git checkout master &&
191
test_tick &&
192
git fetch . left right &&
224
-
193
git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
194
test_cmp expected actual
195
'
196
197
test_expect_success 'merge-msg -F in subdirectory' '
230
-
231
- git config --unset-all merge.log
232
- git config --unset-all merge.summary
198
+ test_might_fail git config --unset-all merge.log &&
199
git config merge.summary yes &&
234
-
200
git checkout master &&
201
test_tick &&
202
git fetch . left right &&
@@ -245,11 +210,11 @@ test_expect_success 'merge-msg -F in subdirectory' '
210
'
211
212
test_expect_success 'merge-msg with nothing to merge' '
248
-
249
- git config --unset-all merge.log
250
- git config --unset-all merge.summary
213
+ test_might_fail git config --unset-all merge.log &&
214
git config merge.summary yes &&
215
216
+ >empty &&
217
+
218
(
219
cd remote &&
220
git checkout -b unrelated &&
@@ -258,22 +223,20 @@ test_expect_success 'merge-msg with nothing to merge' '
223
git fmt-merge-msg <.git/FETCH_HEAD >../actual
224
) &&
225
261
- test_cmp /dev/null actual
226
+ test_cmp empty actual
227
'
228
264
-cat >expected <<\EOF
265
-Merge tag 'tag-r3'
266
-
267
-* tag 'tag-r3':
268
- Right #3
269
- Common #2
270
- Common #1
271
-EOF
272
-
229
test_expect_success 'merge-msg tag' '
230
+ cat >expected <<-EOF &&
231
+ Merge tag ${apos}tag-r3${apos}
232
+
233
+ * tag ${apos}tag-r3${apos}:
234
+ Right #3
235
+ Common #2
236
+ Common #1
237
+ EOF
238
275
- git config --unset-all merge.log
276
- git config --unset-all merge.summary
239
+ test_might_fail git config --unset-all merge.log &&
240
git config merge.summary yes &&
241
242
git checkout master &&
@@ -284,26 +247,24 @@ test_expect_success 'merge-msg tag' '
247
test_cmp expected actual
248
'
249
287
-cat >expected <<\EOF
288
-Merge tags 'tag-r3' and 'tag-l5'
289
-
290
-* tag 'tag-r3':
291
- Right #3
292
- Common #2
293
- Common #1
294
-
295
-* tag 'tag-l5':
296
- Left #5
297
- Left #4
298
- Left #3
299
- Common #2
300
- Common #1
301
-EOF
302
-
250
test_expect_success 'merge-msg two tags' '
304
-
305
- git config --unset-all merge.log
306
- git config --unset-all merge.summary
251
+ cat >expected <<-EOF &&
252
+ Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
253
+
254
+ * tag ${apos}tag-r3${apos}:
255
+ Right #3
256
+ Common #2
257
+ Common #1
258
+
259
+ * tag ${apos}tag-l5${apos}:
260
+ Left #5
261
+ Left #4
262
+ Left #3
263
+ Common #2
264
+ Common #1
265
+ EOF
266
+
267
+ test_might_fail git config --unset-all merge.log &&
268
git config merge.summary yes &&
269
270
git checkout master &&
@@ -314,26 +275,24 @@ test_expect_success 'merge-msg two tags' '
275
test_cmp expected actual
276
'
277
317
-cat >expected <<\EOF
318
-Merge branch 'left', tag 'tag-r3'
319
-
320
-* tag 'tag-r3':
321
- Right #3
322
- Common #2
323
- Common #1
324
-
325
-* left:
326
- Left #5
327
- Left #4
328
- Left #3
329
- Common #2
330
- Common #1
331
-EOF
332
-
278
test_expect_success 'merge-msg tag and branch' '
334
-
335
- git config --unset-all merge.log
336
- git config --unset-all merge.summary
279
+ cat >expected <<-EOF &&
280
+ Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
281
+
282
+ * tag ${apos}tag-r3${apos}:
283
+ Right #3
284
+ Common #2
285
+ Common #1
286
+
287
+ * left:
288
+ Left #5
289
+ Left #4
290
+ Left #3
291
+ Common #2
292
+ Common #1
293
+ EOF
294
+
295
+ test_might_fail git config --unset-all merge.log &&
296
git config merge.summary yes &&
297
298
git checkout master &&
@@ -344,26 +303,27 @@ test_expect_success 'merge-msg tag and branch' '
303
test_cmp expected actual
304
'
305
347
-cat >expected <<\EOF
348
-Merge branch 'long'
349
-
350
-* long: (35 commits)
351
-EOF
352
-
306
test_expect_success 'merge-msg lots of commits' '
307
+ {
308
+ cat <<-EOF &&
309
+ Merge branch ${apos}long${apos}
310
+
311
+ * long: (35 commits)
312
+ EOF
313
+
314
+ i=29 &&
315
+ while test $i -gt 9
316
+ do
317
+ echo " $i" &&
318
+ i=$(($i-1))
319
+ done &&
320
+ echo " ..."
321
+ } >expected &&
322
323
git checkout master &&
324
test_tick &&
325
git fetch . long &&
326
359
- i=29 &&
360
- while test $i -gt 9
361
- do
362
- echo " $i" &&
363
- i=$(($i-1))
364
- done >>expected &&
365
- echo " ..." >>expected
366
-
327
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
328
test_cmp expected actual
329
'