git-p4: Add simple test case for branch import

Create a basic branch structure in P4 and clone it with git-p4. Also, make an update on P4 side and check if git-p4 imports it correctly. The branch structure is created in such a way that git-p4 will fail to import updates if patch "git-p4: Correct branch base depot path detection" is not applied. Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vitor Antunes committed Aug 19, 2011 at 00:44 UTC 7ca97f6ecc66f1d70ca126edd33b6a3065c914f7
1 file changed +64
t/t9800-git-p4.sh
+64
@@ -405,6 +405,70 @@ test_expect_success 'detect copies' '
405 p4 filelog //depot/file13 | grep -q "branch from //depot/file"
406 '
407
408 +# Create a simple branch structure in P4 depot to check if it is correctly
409 +# cloned.
410 +test_expect_success 'add simple p4 branches' '
411 + cd "$cli" &&
412 + mkdir branch1 &&
413 + cd branch1 &&
414 + echo file1 >file1 &&
415 + echo file2 >file2 &&
416 + p4 add file* &&
417 + p4 submit -d "branch1" &&
418 + p4 integrate //depot/branch1/... //depot/branch2/... &&
419 + p4 submit -d "branch2" &&
420 + echo file3 >file3 &&
421 + p4 add file3 &&
422 + p4 submit -d "add file3 in branch1" &&
423 + p4 open file2 &&
424 + echo update >>file2 &&
425 + p4 submit -d "update file2 in branch1" &&
426 + p4 integrate //depot/branch1/... //depot/branch3/... &&
427 + p4 submit -d "branch3" &&
428 + cd "$TRASH_DIRECTORY"
429 +'
430 +
431 +# Configure branches through git-config and clone them.
432 +# All files are tested to make sure branches were cloned correctly.
433 +# Finally, make an update to branch1 on P4 side to check if it is imported
434 +# correctly by git-p4.
435 +test_expect_success 'git-p4 clone simple branches' '
436 + git init "$git" &&
437 + cd "$git" &&
438 + git config git-p4.branchList branch1:branch2 &&
439 + git config --add git-p4.branchList branch1:branch3 &&
440 + cd "$TRASH_DIRECTORY" &&
441 + "$GITP4" clone --dest="$git" --detect-branches //depot@all &&
442 + cd "$git" &&
443 + git log --all --graph --decorate --stat &&
444 + git reset --hard p4/depot/branch1 &&
445 + test -f file1 &&
446 + test -f file2 &&
447 + test -f file3 &&
448 + grep -q update file2 &&
449 + git reset --hard p4/depot/branch2 &&
450 + test -f file1 &&
451 + test -f file2 &&
452 + test \! -z file3 &&
453 + ! grep -q update file2 &&
454 + git reset --hard p4/depot/branch3 &&
455 + test -f file1 &&
456 + test -f file2 &&
457 + test -f file3 &&
458 + grep -q update file2 &&
459 + cd "$cli" &&
460 + cd branch1 &&
461 + p4 edit file2 &&
462 + echo file2_ >> file2 &&
463 + p4 submit -d "update file2 in branch3" &&
464 + cd "$git" &&
465 + git reset --hard p4/depot/branch1 &&
466 + "$GITP4" rebase &&
467 + grep -q file2_ file2 &&
468 + cd "$TRASH_DIRECTORY" &&
469 + rm -rf "$git" && mkdir "$git"
470 +'
471 +
472 test_expect_success 'shutdown' '
473 pid=`pgrep -f p4d` &&
474 test -n "$pid" &&