t / lib-cvs.shon commit cvs tests: do not touch test CVS repositories shipped with source (9b777a1)
   1#!/bin/sh
   2
   3. ./test-lib.sh
   4
   5unset CVS_SERVER
   6# for clean cvsps cache
   7HOME=$(pwd)
   8export HOME
   9
  10if ! type cvs >/dev/null 2>&1
  11then
  12        skip_all='skipping cvsimport tests, cvs not found'
  13        test_done
  14fi
  15
  16CVS="cvs -f"
  17export CVS
  18
  19cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
  20case "$cvsps_version" in
  212.1 | 2.2*)
  22        ;;
  23'')
  24        skip_all='skipping cvsimport tests, cvsps not found'
  25        test_done
  26        ;;
  27*)
  28        skip_all='skipping cvsimport tests, unsupported cvsps version'
  29        test_done
  30        ;;
  31esac
  32
  33setup_cvs_test_repository () {
  34        CVSROOT="$(pwd)/.cvsroot" &&
  35        cp -r "$TEST_DIRECTORY/$1/cvsroot" "$CVSROOT" &&
  36        export CVSROOT
  37}
  38
  39test_cvs_co () {
  40        # Usage: test_cvs_co BRANCH_NAME
  41        rm -rf module-cvs-"$1"
  42        if [ "$1" = "master" ]
  43        then
  44                $CVS co -P -d module-cvs-"$1" -A module
  45        else
  46                $CVS co -P -d module-cvs-"$1" -r "$1" module
  47        fi
  48}
  49
  50test_git_co () {
  51        # Usage: test_git_co BRANCH_NAME
  52        (cd module-git && git checkout "$1")
  53}
  54
  55test_cmp_branch_file () {
  56        # Usage: test_cmp_branch_file BRANCH_NAME PATH
  57        # The branch must already be checked out of CVS and git.
  58        test_cmp module-cvs-"$1"/"$2" module-git/"$2"
  59}
  60
  61test_cmp_branch_tree () {
  62        # Usage: test_cmp_branch_tree BRANCH_NAME
  63        # Check BRANCH_NAME out of CVS and git and make sure that all
  64        # of the files and directories are identical.
  65
  66        test_cvs_co "$1" &&
  67        test_git_co "$1" &&
  68        (
  69                cd module-cvs-"$1"
  70                find . -type d -name CVS -prune -o -type f -print
  71        ) | sort >module-cvs-"$1".list &&
  72        (
  73                cd module-git
  74                find . -type d -name .git -prune -o -type f -print
  75        ) | sort >module-git-"$1".list &&
  76        test_cmp module-cvs-"$1".list module-git-"$1".list &&
  77        cat module-cvs-"$1".list | while read f
  78        do
  79                test_cmp_branch_file "$1" "$f" || return 1
  80        done
  81}