git-p4: Add test case for complex branch import
Check if branches created from old changelists are correctly imported. Also included some updates to simple branch test so that both are coherent in respect to each other. Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Vitor Antunes committed
Jan 25, 2012 at 23:48 UTC
c5665efed2619fae9ec5a57c555c89a91804e886
1 file changed
+87
-7
t/t9801-git-p4-branch.sh
+87
-7
@@ -172,9 +172,9 @@ test_expect_success 'add simple p4 branches' '
172
echo file1 >file1 &&
173
echo file2 >file2 &&
174
p4 add file1 file2 &&
175
- p4 submit -d "branch1" &&
175
+ p4 submit -d "Create branch1" &&
176
p4 integrate //depot/branch1/... //depot/branch2/... &&
177
- p4 submit -d "branch2" &&
177
+ p4 submit -d "Integrate branch2 from branch1" &&
178
echo file3 >file3 &&
179
p4 add file3 &&
180
p4 submit -d "add file3 in branch1" &&
@@ -182,7 +182,7 @@ test_expect_success 'add simple p4 branches' '
182
echo update >>file2 &&
183
p4 submit -d "update file2 in branch1" &&
184
p4 integrate //depot/branch1/... //depot/branch3/... &&
185
- p4 submit -d "branch3"
185
+ p4 submit -d "Integrate branch3 from branch1"
186
)
187
'
188
@@ -203,17 +203,17 @@ test_expect_success 'git-p4 clone simple branches' '
203
test -f file1 &&
204
test -f file2 &&
205
test -f file3 &&
206
- grep -q update file2 &&
206
+ grep update file2 &&
207
git reset --hard p4/depot/branch2 &&
208
test -f file1 &&
209
test -f file2 &&
210
test ! -f file3 &&
211
- test_must_fail grep -q update file2 &&
211
+ test_must_fail grep update file2 &&
212
git reset --hard p4/depot/branch3 &&
213
test -f file1 &&
214
test -f file2 &&
215
test -f file3 &&
216
- grep -q update file2 &&
216
+ grep update file2 &&
217
cd "$cli" &&
218
cd branch1 &&
219
p4 edit file2 &&
@@ -222,7 +222,87 @@ test_expect_success 'git-p4 clone simple branches' '
222
cd "$git" &&
223
git reset --hard p4/depot/branch1 &&
224
"$GITP4" rebase &&
225
- grep -q file2_ file2
225
+ grep file2_ file2
226
+ )
227
+'
228
+
229
+# Create a complex branch structure in P4 depot to check if they are correctly
230
+# cloned. The branches are created from older changelists to check if git-p4 is
231
+# able to correctly detect them.
232
+# The final expected structure is:
233
+# `branch1
234
+# | `- file1
235
+# | `- file2 (updated)
236
+# | `- file3
237
+# `branch2
238
+# | `- file1
239
+# | `- file2
240
+# `branch3
241
+# | `- file1
242
+# | `- file2 (updated)
243
+# | `- file3
244
+# `branch4
245
+# | `- file1
246
+# | `- file2
247
+# `branch5
248
+# `- file1
249
+# `- file2
250
+# `- file3
251
+test_expect_success 'git-p4 add complex branches' '
252
+ test_when_finished cleanup_git &&
253
+ test_create_repo "$git" &&
254
+ (
255
+ cd "$cli" &&
256
+ changelist=$(p4 changes -m1 //depot/... | cut -d" " -f2) &&
257
+ changelist=$(($changelist - 5)) &&
258
+ p4 integrate //depot/branch1/...@$changelist //depot/branch4/... &&
259
+ p4 submit -d "Integrate branch4 from branch1@${changelist}" &&
260
+ changelist=$(($changelist + 2)) &&
261
+ p4 integrate //depot/branch1/...@$changelist //depot/branch5/... &&
262
+ p4 submit -d "Integrate branch5 from branch1@${changelist}"
263
+ )
264
+'
265
+
266
+# Configure branches through git-config and clone them. git-p4 will only be able
267
+# to clone the original structure if it is able to detect the origin changelist
268
+# of each branch.
269
+test_expect_success 'git-p4 clone complex branches' '
270
+ test_when_finished cleanup_git &&
271
+ test_create_repo "$git" &&
272
+ (
273
+ cd "$git" &&
274
+ git config git-p4.branchList branch1:branch2 &&
275
+ git config --add git-p4.branchList branch1:branch3 &&
276
+ git config --add git-p4.branchList branch1:branch4 &&
277
+ git config --add git-p4.branchList branch1:branch5 &&
278
+ "$GITP4" clone --dest=. --detect-branches //depot@all &&
279
+ git log --all --graph --decorate --stat &&
280
+ git reset --hard p4/depot/branch1 &&
281
+ test_path_is_file file1 &&
282
+ test_path_is_file file2 &&
283
+ test_path_is_file file3 &&
284
+ grep update file2 &&
285
+ git reset --hard p4/depot/branch2 &&
286
+ test_path_is_file file1 &&
287
+ test_path_is_file file2 &&
288
+ test_path_is_missing file3 &&
289
+ test_must_fail grep update file2 &&
290
+ git reset --hard p4/depot/branch3 &&
291
+ test_path_is_file file1 &&
292
+ test_path_is_file file2 &&
293
+ test_path_is_file file3 &&
294
+ grep update file2 &&
295
+ git reset --hard p4/depot/branch4 &&
296
+ test_path_is_file file1 &&
297
+ test_path_is_file file2 &&
298
+ test_path_is_missing file3 &&
299
+ test_must_fail grep update file2 &&
300
+ git reset --hard p4/depot/branch5 &&
301
+ test_path_is_file file1 &&
302
+ test_path_is_file file2 &&
303
+ test_path_is_file file3 &&
304
+ test_must_fail grep update file2 &&
305
+ test_path_is_missing .git/git-p4-tmp
306
)
307
'
308