t / t9800-git-p4.shon commit Merge branch 'mm/push-default-advice' (bde7f73)
   1#!/bin/sh
   2
   3test_description='git-p4 tests'
   4
   5. ./test-lib.sh
   6
   7( p4 -h && p4d -h ) >/dev/null 2>&1 || {
   8        skip_all='skipping git-p4 tests; no p4 or p4d'
   9        test_done
  10}
  11
  12GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4
  13P4DPORT=10669
  14
  15db="$TRASH_DIRECTORY/db"
  16cli="$TRASH_DIRECTORY/cli"
  17git="$TRASH_DIRECTORY/git"
  18
  19test_debug 'echo p4d -q -d -r "$db" -p $P4DPORT'
  20test_expect_success setup '
  21        mkdir -p "$db" &&
  22        p4d -q -d -r "$db" -p $P4DPORT &&
  23        mkdir -p "$cli" &&
  24        mkdir -p "$git" &&
  25        export P4PORT=localhost:$P4DPORT
  26'
  27
  28test_expect_success 'add p4 files' '
  29        cd "$cli" &&
  30        p4 client -i <<-EOF &&
  31        Client: client
  32        Description: client
  33        Root: $cli
  34        View: //depot/... //client/...
  35        EOF
  36        export P4CLIENT=client &&
  37        echo file1 >file1 &&
  38        p4 add file1 &&
  39        p4 submit -d "file1" &&
  40        echo file2 >file2 &&
  41        p4 add file2 &&
  42        p4 submit -d "file2" &&
  43        cd "$TRASH_DIRECTORY"
  44'
  45
  46test_expect_success 'basic git-p4 clone' '
  47        "$GITP4" clone --dest="$git" //depot &&
  48        cd "$git" &&
  49        git log --oneline >lines &&
  50        test_line_count = 1 lines &&
  51        cd .. &&
  52        rm -rf "$git" && mkdir "$git"
  53'
  54
  55test_expect_success 'git-p4 clone @all' '
  56        "$GITP4" clone --dest="$git" //depot@all &&
  57        cd "$git" &&
  58        git log --oneline >lines &&
  59        test_line_count = 2 lines &&
  60        cd .. &&
  61        rm -rf "$git" && mkdir "$git"
  62'
  63
  64test_expect_success 'exit when p4 fails to produce marshaled output' '
  65        badp4dir="$TRASH_DIRECTORY/badp4dir" &&
  66        mkdir -p "$badp4dir" &&
  67        cat >"$badp4dir"/p4 <<-EOF &&
  68        #!$SHELL_PATH
  69        exit 1
  70        EOF
  71        chmod 755 "$badp4dir"/p4 &&
  72        PATH="$badp4dir:$PATH" "$GITP4" clone --dest="$git" //depot >errs 2>&1 ; retval=$? &&
  73        test $retval -eq 1 &&
  74        test_must_fail grep -q Traceback errs
  75'
  76
  77test_expect_success 'add p4 files with wildcards in the names' '
  78        cd "$cli" &&
  79        echo file-wild-hash >file-wild#hash &&
  80        echo file-wild-star >file-wild\*star &&
  81        echo file-wild-at >file-wild@at &&
  82        echo file-wild-percent >file-wild%percent &&
  83        p4 add -f file-wild* &&
  84        p4 submit -d "file wildcards" &&
  85        cd "$TRASH_DIRECTORY"
  86'
  87
  88test_expect_success 'wildcard files git-p4 clone' '
  89        "$GITP4" clone --dest="$git" //depot &&
  90        cd "$git" &&
  91        test -f file-wild#hash &&
  92        test -f file-wild\*star &&
  93        test -f file-wild@at &&
  94        test -f file-wild%percent &&
  95        cd "$TRASH_DIRECTORY" &&
  96        rm -rf "$git" && mkdir "$git"
  97'
  98
  99test_expect_success 'clone bare' '
 100        "$GITP4" clone --dest="$git" --bare //depot &&
 101        cd "$git" &&
 102        test ! -d .git &&
 103        bare=`git config --get core.bare` &&
 104        test "$bare" = true &&
 105        cd "$TRASH_DIRECTORY" &&
 106        rm -rf "$git" && mkdir "$git"
 107'
 108
 109test_expect_success 'shutdown' '
 110        pid=`pgrep -f p4d` &&
 111        test -n "$pid" &&
 112        test_debug "ps wl `echo $pid`" &&
 113        kill $pid
 114'
 115
 116test_done