t / t9400-git-cvsserver-server.shon commit Merge branch 'sv/checkout' (063581e)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Frank Lichtenheld
   4#
   5
   6test_description='git-cvsserver access
   7
   8tests read access to a git repository with the
   9cvs CLI client via git-cvsserver server'
  10
  11. ./test-lib.sh
  12
  13cvs >/dev/null 2>&1
  14if test $? -ne 1
  15then
  16    test_expect_success 'skipping git-cvsserver tests, cvs not found' :
  17    test_done
  18    exit
  19fi
  20perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
  21    test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
  22    test_done
  23    exit
  24}
  25
  26unset GIT_DIR GIT_CONFIG
  27WORKDIR=$(pwd)
  28SERVERDIR=$(pwd)/gitcvs.git
  29git_config="$SERVERDIR/config"
  30CVSROOT=":fork:$SERVERDIR"
  31CVSWORK="$(pwd)/cvswork"
  32CVS_SERVER=git-cvsserver
  33export CVSROOT CVS_SERVER
  34
  35rm -rf "$CVSWORK" "$SERVERDIR"
  36echo >empty &&
  37  git add empty &&
  38  git commit -q -m "First Commit" &&
  39  git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
  40  GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
  41  GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
  42  exit 1
  43
  44# note that cvs doesn't accept absolute pathnames
  45# as argument to co -d
  46test_expect_success 'basic checkout' \
  47  'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
  48   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
  49
  50test_expect_success 'cvs update (create new file)' \
  51  'echo testfile1 >testfile1 &&
  52   git add testfile1 &&
  53   git commit -q -m "Add testfile1" &&
  54   git push gitcvs.git >/dev/null &&
  55   cd cvswork &&
  56   GIT_CONFIG="$git_config" cvs -Q update &&
  57   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
  58   diff -q testfile1 ../testfile1'
  59
  60cd "$WORKDIR"
  61test_expect_success 'cvs update (update existing file)' \
  62  'echo line 2 >>testfile1 &&
  63   git add testfile1 &&
  64   git commit -q -m "Append to testfile1" &&
  65   git push gitcvs.git >/dev/null &&
  66   cd cvswork &&
  67   GIT_CONFIG="$git_config" cvs -Q update &&
  68   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
  69   diff -q testfile1 ../testfile1'
  70
  71cd "$WORKDIR"
  72#TODO: cvsserver doesn't support update w/o -d
  73test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
  74  'mkdir test &&
  75   echo >test/empty &&
  76   git add test &&
  77   git commit -q -m "Single Subdirectory" &&
  78   git push gitcvs.git >/dev/null &&
  79   cd cvswork &&
  80   GIT_CONFIG="$git_config" cvs -Q update &&
  81   test ! -d test'
  82
  83cd "$WORKDIR"
  84test_expect_success 'cvs update (subdirectories)' \
  85  '(for dir in A A/B A/B/C A/D E; do
  86      mkdir $dir &&
  87      echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")"  &&
  88      git add $dir;
  89   done) &&
  90   git commit -q -m "deep sub directory structure" &&
  91   git push gitcvs.git >/dev/null &&
  92   cd cvswork &&
  93   GIT_CONFIG="$git_config" cvs -Q update -d &&
  94   (for dir in A A/B A/B/C A/D E; do
  95      filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
  96      if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
  97           diff -q "$dir/$filename" "../$dir/$filename"; then
  98        :
  99      else
 100        echo >failure
 101      fi
 102    done) &&
 103   test ! -f failure'
 104
 105cd "$WORKDIR"
 106test_expect_success 'cvs update (delete file)' \
 107  'git rm testfile1 &&
 108   git commit -q -m "Remove testfile1" &&
 109   git push gitcvs.git >/dev/null &&
 110   cd cvswork &&
 111   GIT_CONFIG="$git_config" cvs -Q update &&
 112   test -z "$(grep testfile1 CVS/Entries)" &&
 113   test ! -f testfile1'
 114
 115cd "$WORKDIR"
 116test_expect_success 'cvs update (re-add deleted file)' \
 117  'echo readded testfile >testfile1 &&
 118   git add testfile1 &&
 119   git commit -q -m "Re-Add testfile1" &&
 120   git push gitcvs.git >/dev/null &&
 121   cd cvswork &&
 122   GIT_CONFIG="$git_config" cvs -Q update &&
 123   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
 124   diff -q testfile1 ../testfile1'
 125
 126test_done