1#!/bin/sh
   2test_description='git-cvsimport basic tests'
   4. ./test-lib.sh
   5CVSROOT=$(pwd)/cvsroot
   7export CVSROOT
   8unset CVS_SERVER
   9# for clean cvsps cache
  10HOME=$(pwd)
  11export HOME
  12if ! type cvs >/dev/null 2>&1
  14then
  15        say 'skipping cvsimport tests, cvs not found'
  16        test_done
  17        exit
  18fi
  19cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
  21case "$cvsps_version" in
  222.1 | 2.2*)
  23        ;;
  24'')
  25        say 'skipping cvsimport tests, cvsps not found'
  26        test_done
  27        exit
  28        ;;
  29*)
  30        say 'skipping cvsimport tests, unsupported cvsps version'
  31        test_done
  32        exit
  33        ;;
  34esac
  35test_expect_success 'setup cvsroot' 'cvs init'
  37test_expect_success 'setup a cvs module' '
  39        mkdir "$CVSROOT/module" &&
  41        cvs co -d module-cvs module &&
  42        cd module-cvs &&
  43        cat <<EOF >o_fortuna &&
  44O Fortuna
  45velut luna
  46statu variabilis,
  47semper crescis
  49aut decrescis;
  50vita detestabilis
  51nunc obdurat
  53et tunc curat
  54ludo mentis aciem,
  55egestatem,
  57potestatem
  58dissolvit ut glaciem.
  59EOF
  60        cvs add o_fortuna &&
  61        cat <<EOF >message &&
  62add "O Fortuna" lyrics
  63These public domain lyrics make an excellent sample text.
  65EOF
  66        cvs commit -F message &&
  67        cd ..
  68'
  69test_expect_success 'import a trivial module' '
  71        git cvsimport -a -z 0 -C module-git module &&
  73        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  74'
  76test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
  78test_expect_success 'update cvs module' '
  80        cd module-cvs &&
  82        cat <<EOF >o_fortuna &&
  83O Fortune,
  84like the moon
  85you are changeable,
  86ever waxing
  88and waning;
  89hateful life
  90first oppresses
  92and then soothes
  93as fancy takes it;
  94poverty
  96and power
  97it melts them like ice.
  98EOF
  99        cat <<EOF >message &&
 100translate to English
 101My Latin is terrible.
 103EOF
 104        cvs commit -F message &&
 105        cd ..
 106'
 107test_expect_success 'update git module' '
 109        cd module-git &&
 111        git cvsimport -a -z 0 module &&
 112        git merge origin &&
 113        cd .. &&
 114        test_cmp module-cvs/o_fortuna module-git/o_fortuna
 115'
 117test_expect_success 'update cvs module' '
 119        cd module-cvs &&
 121                echo 1 >tick &&
 122                cvs add tick &&
 123                cvs commit -m 1
 124        cd ..
 125'
 127test_expect_success 'cvsimport.module config works' '
 129        cd module-git &&
 131                git config cvsimport.module module &&
 132                git cvsimport -a -z0 &&
 133                git merge origin &&
 134        cd .. &&
 135        test_cmp module-cvs/tick module-git/tick
 136'
 138test_expect_success 'import from a CVS working tree' '
 140        cvs co -d import-from-wt module &&
 142        cd import-from-wt &&
 143                git cvsimport -a -z0 &&
 144                echo 1 >expect &&
 145                git log -1 --pretty=format:%s%n >actual &&
 146                test_cmp actual expect &&
 147        cd ..
 148'
 150test_done