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