t / t9816-git-p4-locked.shon commit test-lib-functions.sh: remove misleading comment on test_seq (55672a3)
   1#!/bin/sh
   2
   3test_description='git p4 locked file behavior'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11# See
  12# http://www.perforce.com/perforce/doc.current/manuals/p4sag/03_superuser.html#1088563
  13# for suggestions on how to configure "sitewide pessimistic locking"
  14# where only one person can have a file open for edit at a time.
  15test_expect_success 'init depot' '
  16        (
  17                cd "$cli" &&
  18                echo "TypeMap: +l //depot/..." | p4 typemap -i &&
  19                echo file1 >file1 &&
  20                p4 add file1 &&
  21                p4 submit -d "add file1"
  22        )
  23'
  24
  25test_expect_success 'edit with lock not taken' '
  26        test_when_finished cleanup_git &&
  27        git p4 clone --dest="$git" //depot &&
  28        (
  29                cd "$git" &&
  30                echo line2 >>file1 &&
  31                git add file1 &&
  32                git commit -m "line2 in file1" &&
  33                git config git-p4.skipSubmitEdit true &&
  34                git p4 submit
  35        )
  36'
  37
  38test_expect_failure 'add with lock not taken' '
  39        test_when_finished cleanup_git &&
  40        git p4 clone --dest="$git" //depot &&
  41        (
  42                cd "$git" &&
  43                echo line1 >>add-lock-not-taken &&
  44                git add file2 &&
  45                git commit -m "add add-lock-not-taken" &&
  46                git config git-p4.skipSubmitEdit true &&
  47                git p4 submit --verbose
  48        )
  49'
  50
  51lock_in_another_client() {
  52        # build a different client
  53        cli2="$TRASH_DIRECTORY/cli2" &&
  54        mkdir -p "$cli2" &&
  55        test_when_finished "p4 client -f -d client2 && rm -rf \"$cli2\"" &&
  56        (
  57                cd "$cli2" &&
  58                P4CLIENT=client2 &&
  59                cli="$cli2" &&
  60                client_view "//depot/... //client2/..." &&
  61                p4 sync &&
  62                p4 open file1
  63        )
  64}
  65
  66test_expect_failure 'edit with lock taken' '
  67        lock_in_another_client &&
  68        test_when_finished cleanup_git &&
  69        test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
  70        git p4 clone --dest="$git" //depot &&
  71        (
  72                cd "$git" &&
  73                echo line3 >>file1 &&
  74                git add file1 &&
  75                git commit -m "line3 in file1" &&
  76                git config git-p4.skipSubmitEdit true &&
  77                git p4 submit --verbose
  78        )
  79'
  80
  81test_expect_failure 'delete with lock taken' '
  82        lock_in_another_client &&
  83        test_when_finished cleanup_git &&
  84        test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
  85        git p4 clone --dest="$git" //depot &&
  86        (
  87                cd "$git" &&
  88                git rm file1 &&
  89                git commit -m "delete file1" &&
  90                git config git-p4.skipSubmitEdit true &&
  91                git p4 submit --verbose
  92        )
  93'
  94
  95test_expect_failure 'chmod with lock taken' '
  96        lock_in_another_client &&
  97        test_when_finished cleanup_git &&
  98        test_when_finished "cd \"$cli\" && p4 sync -f file1" &&
  99        git p4 clone --dest="$git" //depot &&
 100        (
 101                cd "$git" &&
 102                chmod +x file1 &&
 103                git add file1 &&
 104                git commit -m "chmod +x file1" &&
 105                git config git-p4.skipSubmitEdit true &&
 106                git p4 submit --verbose
 107        )
 108'
 109
 110test_expect_failure 'copy with lock taken' '
 111        lock_in_another_client &&
 112        test_when_finished cleanup_git &&
 113        test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" &&
 114        git p4 clone --dest="$git" //depot &&
 115        (
 116                cd "$git" &&
 117                cp file1 file2 &&
 118                git add file2 &&
 119                git commit -m "cp file1 to file2" &&
 120                git config git-p4.skipSubmitEdit true &&
 121                git config git-p4.detectCopies true &&
 122                git p4 submit --verbose
 123        )
 124'
 125
 126test_expect_failure 'move with lock taken' '
 127        lock_in_another_client &&
 128        test_when_finished cleanup_git &&
 129        test_when_finished "cd \"$cli\" && p4 sync file1 && rm -f file2" &&
 130        git p4 clone --dest="$git" //depot &&
 131        (
 132                cd "$git" &&
 133                git mv file1 file2 &&
 134                git commit -m "mv file1 to file2" &&
 135                git config git-p4.skipSubmitEdit true &&
 136                git config git-p4.detectRenames true &&
 137                git p4 submit --verbose
 138        )
 139'
 140
 141test_expect_success 'kill p4d' '
 142        kill_p4d
 143'
 144
 145test_done