1#!/bin/sh
   2test_description='git cvsimport basic tests'
   4. ./lib-cvs.sh
   5if ! test_have_prereq PERL; then
   7        say 'skipping git cvsimport tests, perl not available'
   8        test_done
   9fi
  10CVSROOT=$(pwd)/cvsroot
  12export CVSROOT
  13test_expect_success 'setup cvsroot' '$CVS init'
  15test_expect_success 'setup a cvs module' '
  17        mkdir "$CVSROOT/module" &&
  19        $CVS co -d module-cvs module &&
  20        cd module-cvs &&
  21        cat <<EOF >o_fortuna &&
  22O Fortuna
  23velut luna
  24statu variabilis,
  25semper crescis
  27aut decrescis;
  28vita detestabilis
  29nunc obdurat
  31et tunc curat
  32ludo mentis aciem,
  33egestatem,
  35potestatem
  36dissolvit ut glaciem.
  37EOF
  38        $CVS add o_fortuna &&
  39        cat <<EOF >message &&
  40add "O Fortuna" lyrics
  41These public domain lyrics make an excellent sample text.
  43EOF
  44        $CVS commit -F message &&
  45        cd ..
  46'
  47test_expect_success 'import a trivial module' '
  49        git cvsimport -a -z 0 -C module-git module &&
  51        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  52'
  54test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
  56test_expect_success 'update cvs module' '
  58        cd module-cvs &&
  60        cat <<EOF >o_fortuna &&
  61O Fortune,
  62like the moon
  63you are changeable,
  64ever waxing
  66and waning;
  67hateful life
  68first oppresses
  70and then soothes
  71as fancy takes it;
  72poverty
  74and power
  75it melts them like ice.
  76EOF
  77        cat <<EOF >message &&
  78translate to English
  79My Latin is terrible.
  81EOF
  82        $CVS commit -F message &&
  83        cd ..
  84'
  85test_expect_success 'update git module' '
  87        cd module-git &&
  89        git cvsimport -a -z 0 module &&
  90        git merge origin &&
  91        cd .. &&
  92        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  93'
  95test_expect_success 'update cvs module' '
  97        cd module-cvs &&
  99                echo 1 >tick &&
 100                $CVS add tick &&
 101                $CVS commit -m 1
 102        cd ..
 103'
 105test_expect_success 'cvsimport.module config works' '
 107        cd module-git &&
 109                git config cvsimport.module module &&
 110                git cvsimport -a -z0 &&
 111                git merge origin &&
 112        cd .. &&
 113        test_cmp module-cvs/tick module-git/tick
 114'
 116test_expect_success 'import from a CVS working tree' '
 118        $CVS co -d import-from-wt module &&
 120        cd import-from-wt &&
 121                git cvsimport -a -z0 &&
 122                echo 1 >expect &&
 123                git log -1 --pretty=format:%s%n >actual &&
 124                test_cmp actual expect &&
 125        cd ..
 126'
 128test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'
 130test_done