t / lib-cvs.shon commit Merge branch 'jc/shortstatus' (433233e)
   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        say '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        say 'skipping cvsimport tests, cvsps not found'
  25        test_done
  26        ;;
  27*)
  28        say 'skipping cvsimport tests, unsupported cvsps version'
  29        test_done
  30        ;;
  31esac
  32
  33test_cvs_co () {
  34        # Usage: test_cvs_co BRANCH_NAME
  35        rm -rf module-cvs-"$1"
  36        if [ "$1" = "master" ]
  37        then
  38                $CVS co -P -d module-cvs-"$1" -A module
  39        else
  40                $CVS co -P -d module-cvs-"$1" -r "$1" module
  41        fi
  42}
  43
  44test_git_co () {
  45        # Usage: test_git_co BRANCH_NAME
  46        (cd module-git && git checkout "$1")
  47}
  48
  49test_cmp_branch_file () {
  50        # Usage: test_cmp_branch_file BRANCH_NAME PATH
  51        # The branch must already be checked out of CVS and git.
  52        test_cmp module-cvs-"$1"/"$2" module-git/"$2"
  53}
  54
  55test_cmp_branch_tree () {
  56        # Usage: test_cmp_branch_tree BRANCH_NAME
  57        # Check BRANCH_NAME out of CVS and git and make sure that all
  58        # of the files and directories are identical.
  59
  60        test_cvs_co "$1" &&
  61        test_git_co "$1" &&
  62        (
  63                cd module-cvs-"$1"
  64                find . -type d -name CVS -prune -o -type f -print
  65        ) | sort >module-cvs-"$1".list &&
  66        (
  67                cd module-git
  68                find . -type d -name .git -prune -o -type f -print
  69        ) | sort >module-git-"$1".list &&
  70        test_cmp module-cvs-"$1".list module-git-"$1".list &&
  71        cat module-cvs-"$1".list | while read f
  72        do
  73                test_cmp_branch_file "$1" "$f" || return 1
  74        done
  75}