t / t9600-cvsimport.shon commit cvs tests: do not touch test CVS repositories shipped with source (9b777a1)
   1#!/bin/sh
   2
   3test_description='git cvsimport basic tests'
   4. ./lib-cvs.sh
   5
   6test_expect_success PERL 'setup cvsroot environment' '
   7        CVSROOT=$(pwd)/cvsroot &&
   8        export CVSROOT
   9'
  10
  11test_expect_success PERL 'setup cvsroot' '$CVS init'
  12
  13test_expect_success PERL 'setup a cvs module' '
  14
  15        mkdir "$CVSROOT/module" &&
  16        $CVS co -d module-cvs module &&
  17        cd module-cvs &&
  18        cat <<EOF >o_fortuna &&
  19O Fortuna
  20velut luna
  21statu variabilis,
  22
  23semper crescis
  24aut decrescis;
  25vita detestabilis
  26
  27nunc obdurat
  28et tunc curat
  29ludo mentis aciem,
  30
  31egestatem,
  32potestatem
  33dissolvit ut glaciem.
  34EOF
  35        $CVS add o_fortuna &&
  36        cat <<EOF >message &&
  37add "O Fortuna" lyrics
  38
  39These public domain lyrics make an excellent sample text.
  40EOF
  41        $CVS commit -F message &&
  42        cd ..
  43'
  44
  45test_expect_success PERL 'import a trivial module' '
  46
  47        git cvsimport -a -R -z 0 -C module-git module &&
  48        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  49
  50'
  51
  52test_expect_success PERL 'pack refs' 'cd module-git && git gc && cd ..'
  53
  54test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
  55
  56        (cd module-git &&
  57         git log --format="o_fortuna 1.1 %H" -1) > expected &&
  58        test_cmp expected module-git/.git/cvs-revisions
  59'
  60
  61test_expect_success PERL 'update cvs module' '
  62
  63        cd module-cvs &&
  64        cat <<EOF >o_fortuna &&
  65O Fortune,
  66like the moon
  67you are changeable,
  68
  69ever waxing
  70and waning;
  71hateful life
  72
  73first oppresses
  74and then soothes
  75as fancy takes it;
  76
  77poverty
  78and power
  79it melts them like ice.
  80EOF
  81        cat <<EOF >message &&
  82translate to English
  83
  84My Latin is terrible.
  85EOF
  86        $CVS commit -F message &&
  87        cd ..
  88'
  89
  90test_expect_success PERL 'update git module' '
  91
  92        cd module-git &&
  93        git cvsimport -a -R -z 0 module &&
  94        git merge origin &&
  95        cd .. &&
  96        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  97
  98'
  99
 100test_expect_success PERL 'update has correct .git/cvs-revisions' '
 101
 102        (cd module-git &&
 103         git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
 104         git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected &&
 105        test_cmp expected module-git/.git/cvs-revisions
 106'
 107
 108test_expect_success PERL 'update cvs module' '
 109
 110        cd module-cvs &&
 111                echo 1 >tick &&
 112                $CVS add tick &&
 113                $CVS commit -m 1
 114        cd ..
 115
 116'
 117
 118test_expect_success PERL 'cvsimport.module config works' '
 119
 120        cd module-git &&
 121                git config cvsimport.module module &&
 122                git cvsimport -a -R -z0 &&
 123                git merge origin &&
 124        cd .. &&
 125        test_cmp module-cvs/tick module-git/tick
 126
 127'
 128
 129test_expect_success PERL 'second update has correct .git/cvs-revisions' '
 130
 131        (cd module-git &&
 132         git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
 133         git log --format="o_fortuna 1.2 %H" -1 HEAD^
 134         git log --format="tick 1.1 %H" -1 HEAD) > expected &&
 135        test_cmp expected module-git/.git/cvs-revisions
 136'
 137
 138test_expect_success PERL 'import from a CVS working tree' '
 139
 140        $CVS co -d import-from-wt module &&
 141        cd import-from-wt &&
 142                git cvsimport -a -z0 &&
 143                echo 1 >expect &&
 144                git log -1 --pretty=format:%s%n >actual &&
 145                test_cmp actual expect &&
 146        cd ..
 147
 148'
 149
 150test_expect_success PERL 'no .git/cvs-revisions created by default' '
 151
 152        ! test -e import-from-wt/.git/cvs-revisions
 153
 154'
 155
 156test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
 157
 158test_done