t / t9600-cvsimport.shon commit Merge branch 'jc/maint-checkout-keep-remove' into maint (2ba3d5d)
   1#!/bin/sh
   2
   3test_description='git-cvsimport basic tests'
   4. ./test-lib.sh
   5
   6CVSROOT=$(pwd)/cvsroot
   7export CVSROOT
   8unset CVS_SERVER
   9# for clean cvsps cache
  10HOME=$(pwd)
  11export HOME
  12
  13if ! type cvs >/dev/null 2>&1
  14then
  15        say 'skipping cvsimport tests, cvs not found'
  16        test_done
  17        exit
  18fi
  19
  20cvsps_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
  35
  36test_expect_success 'setup cvsroot' 'cvs init'
  37
  38test_expect_success 'setup a cvs module' '
  39
  40        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,
  47
  48semper crescis
  49aut decrescis;
  50vita detestabilis
  51
  52nunc obdurat
  53et tunc curat
  54ludo mentis aciem,
  55
  56egestatem,
  57potestatem
  58dissolvit ut glaciem.
  59EOF
  60        cvs add o_fortuna &&
  61        cat <<EOF >message &&
  62add "O Fortuna" lyrics
  63
  64These public domain lyrics make an excellent sample text.
  65EOF
  66        cvs commit -F message &&
  67        cd ..
  68'
  69
  70test_expect_success 'import a trivial module' '
  71
  72        git cvsimport -a -z 0 -C module-git module &&
  73        test_cmp module-cvs/o_fortuna module-git/o_fortuna
  74
  75'
  76
  77test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
  78
  79test_expect_success 'update cvs module' '
  80
  81        cd module-cvs &&
  82        cat <<EOF >o_fortuna &&
  83O Fortune,
  84like the moon
  85you are changeable,
  86
  87ever waxing
  88and waning;
  89hateful life
  90
  91first oppresses
  92and then soothes
  93as fancy takes it;
  94
  95poverty
  96and power
  97it melts them like ice.
  98EOF
  99        cat <<EOF >message &&
 100translate to English
 101
 102My Latin is terrible.
 103EOF
 104        cvs commit -F message &&
 105        cd ..
 106'
 107
 108test_expect_success 'update git module' '
 109
 110        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
 116'
 117
 118test_expect_success 'update cvs module' '
 119
 120        cd module-cvs &&
 121                echo 1 >tick &&
 122                cvs add tick &&
 123                cvs commit -m 1
 124        cd ..
 125
 126'
 127
 128test_expect_success 'cvsimport.module config works' '
 129
 130        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
 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        cd ..
 148
 149'
 150
 151test_done