t / t9600-cvsimport.shon commit Allow tracking branches to set up rebase by default. (c998ae9)
   1#!/bin/sh
   2
   3test_description='git-cvsimport basic tests'
   4. ./test-lib.sh
   5
   6CVSROOT=$(pwd)/cvsroot
   7export CVSROOT
   8# for clean cvsps cache
   9HOME=$(pwd)
  10export HOME
  11
  12if ! type cvs >/dev/null 2>&1
  13then
  14        say 'skipping cvsimport tests, cvs not found'
  15        test_done
  16        exit
  17fi
  18
  19cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
  20case "$cvsps_version" in
  212.1)
  22        ;;
  23'')
  24        say 'skipping cvsimport tests, cvsps not found'
  25        test_done
  26        exit
  27        ;;
  28*)
  29        say 'skipping cvsimport tests, cvsps too old'
  30        test_done
  31        exit
  32        ;;
  33esac
  34
  35test_expect_success 'setup cvsroot' 'cvs init'
  36
  37test_expect_success 'setup a cvs module' '
  38
  39        mkdir $CVSROOT/module &&
  40        cvs co -d module-cvs module &&
  41        cd module-cvs &&
  42        cat <<EOF >o_fortuna &&
  43O Fortuna
  44velut luna
  45statu variabilis,
  46
  47semper crescis
  48aut decrescis;
  49vita detestabilis
  50
  51nunc obdurat
  52et tunc curat
  53ludo mentis aciem,
  54
  55egestatem,
  56potestatem
  57dissolvit ut glaciem.
  58EOF
  59        cvs add o_fortuna &&
  60        cat <<EOF >message &&
  61add "O Fortuna" lyrics
  62
  63These public domain lyrics make an excellent sample text.
  64EOF
  65        cvs commit -F message &&
  66        cd ..
  67'
  68
  69test_expect_success 'import a trivial module' '
  70
  71        git cvsimport -a -z 0 -C module-git module &&
  72        git diff module-cvs/o_fortuna module-git/o_fortuna
  73
  74'
  75
  76test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
  77
  78test_expect_success 'update cvs module' '
  79
  80        cd module-cvs &&
  81        cat <<EOF >o_fortuna &&
  82O Fortune,
  83like the moon
  84you are changeable,
  85
  86ever waxing
  87and waning;
  88hateful life
  89
  90first oppresses
  91and then soothes
  92as fancy takes it;
  93
  94poverty
  95and power
  96it melts them like ice.
  97EOF
  98        cat <<EOF >message &&
  99translate to English
 100
 101My Latin is terrible.
 102EOF
 103        cvs commit -F message &&
 104        cd ..
 105'
 106
 107test_expect_success 'update git module' '
 108
 109        cd module-git &&
 110        git cvsimport -a -z 0 module &&
 111        git merge origin &&
 112        cd .. &&
 113        git diff module-cvs/o_fortuna module-git/o_fortuna
 114
 115'
 116
 117test_expect_success 'update cvs module' '
 118
 119        cd module-cvs &&
 120                echo 1 >tick &&
 121                cvs add tick &&
 122                cvs commit -m 1
 123        cd ..
 124
 125'
 126
 127test_expect_success 'cvsimport.module config works' '
 128
 129        cd module-git &&
 130                git config cvsimport.module module &&
 131                git cvsimport -a -z0 &&
 132                git merge origin &&
 133        cd .. &&
 134        git diff module-cvs/tick module-git/tick
 135
 136'
 137
 138test_expect_success '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                git diff actual expect &&
 146        cd ..
 147
 148'
 149
 150test_done