t / lib-git-svn.shon commit i18n: make GETTEXT_POISON a runtime option (6cdccfc)
   1. ./test-lib.sh
   2
   3if test -n "$NO_SVN_TESTS"
   4then
   5        skip_all='skipping git svn tests, NO_SVN_TESTS defined'
   6        test_done
   7fi
   8if ! test_have_prereq PERL; then
   9        skip_all='skipping git svn tests, perl not available'
  10        test_done
  11fi
  12
  13GIT_DIR=$PWD/.git
  14GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
  15SVN_TREE=$GIT_SVN_DIR/svn-tree
  16
  17svn >/dev/null 2>&1
  18if test $? -ne 1
  19then
  20        skip_all='skipping git svn tests, svn not found'
  21        test_done
  22fi
  23
  24svnrepo=$PWD/svnrepo
  25export svnrepo
  26svnconf=$PWD/svnconf
  27export svnconf
  28
  29perl -w -e "
  30use SVN::Core;
  31use SVN::Repos;
  32\$SVN::Core::VERSION gt '1.1.0' or exit(42);
  33system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
  34" >&3 2>&4
  35x=$?
  36if test $x -ne 0
  37then
  38        if test $x -eq 42; then
  39                skip_all='Perl SVN libraries must be >= 1.1.0'
  40        elif test $x -eq 41; then
  41                skip_all='svnadmin failed to create fsfs repository'
  42        else
  43                skip_all='Perl SVN libraries not found or unusable'
  44        fi
  45        test_done
  46fi
  47
  48rawsvnrepo="$svnrepo"
  49svnrepo="file://$svnrepo"
  50
  51poke() {
  52        test-tool chmtime +1 "$1"
  53}
  54
  55# We need this, because we should pass empty configuration directory to
  56# the 'svn commit' to avoid automated property changes and other stuff
  57# that could be set from user's configuration files in ~/.subversion.
  58svn_cmd () {
  59        [ -d "$svnconf" ] || mkdir "$svnconf"
  60        orig_svncmd="$1"; shift
  61        if [ -z "$orig_svncmd" ]; then
  62                svn
  63                return
  64        fi
  65        svn "$orig_svncmd" --config-dir "$svnconf" "$@"
  66}
  67
  68maybe_start_httpd () {
  69        loc=${1-svn}
  70
  71        test_tristate GIT_SVN_TEST_HTTPD
  72        case $GIT_SVN_TEST_HTTPD in
  73        true)
  74                . "$TEST_DIRECTORY"/lib-httpd.sh
  75                LIB_HTTPD_SVN="$loc"
  76                start_httpd
  77                ;;
  78        *)
  79                stop_httpd () {
  80                        : noop
  81                }
  82                ;;
  83        esac
  84}
  85
  86convert_to_rev_db () {
  87        perl -w -- - "$@" <<\EOF
  88use strict;
  89@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
  90open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
  91open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
  92my $size = (stat($rd))[7];
  93($size % 24) == 0 or die "Inconsistent size: $size";
  94while (sysread($rd, my $buf, 24) == 24) {
  95        my ($r, $c) = unpack('NH40', $buf);
  96        my $offset = $r * 41;
  97        seek $wr, 0, 2 or die $!;
  98        my $pos = tell $wr;
  99        if ($pos < $offset) {
 100                for (1 .. (($offset - $pos) / 41)) {
 101                        print $wr (('0' x 40),"\n") or die $!;
 102                }
 103        }
 104        seek $wr, $offset, 0 or die $!;
 105        print $wr $c,"\n" or die $!;
 106}
 107close $wr or die $!;
 108close $rd or die $!;
 109EOF
 110}
 111
 112require_svnserve () {
 113        test_tristate GIT_TEST_SVNSERVE
 114        if ! test "$GIT_TEST_SVNSERVE" = true
 115        then
 116                skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
 117                test_done
 118        fi
 119}
 120
 121start_svnserve () {
 122        SVNSERVE_PORT=${SVNSERVE_PORT-${this_test#t}}
 123        svnserve --listen-port $SVNSERVE_PORT \
 124                 --root "$rawsvnrepo" \
 125                 --listen-once \
 126                 --listen-host 127.0.0.1 &
 127}
 128
 129prepare_a_utf8_locale () {
 130        a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
 131        p
 132        q
 133}')
 134        if test -n "$a_utf8_locale"
 135        then
 136                test_set_prereq UTF8
 137        else
 138                say "# UTF-8 locale not available, some tests are skipped"
 139        fi
 140}