]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-git-svn.sh
Merge branch 'dl/reset-doc-no-wrt-abbrev'
[thirdparty/git.git] / t / lib-git-svn.sh
CommitLineData
60d02ccc
EW
1. ./test-lib.sh
2
3if test -n "$NO_SVN_TESTS"
36f5b1f0 4then
fadb5156 5 skip_all='skipping git svn tests, NO_SVN_TESTS defined'
60d02ccc 6 test_done
36f5b1f0 7fi
1b19ccd2 8if ! test_have_prereq PERL; then
fadb5156 9 skip_all='skipping git svn tests, perl not available'
1b19ccd2
JK
10 test_done
11fi
36f5b1f0 12
b9c85187 13GIT_DIR=$PWD/.git
6f5748e1 14GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
b9c85187 15SVN_TREE=$GIT_SVN_DIR/svn-tree
fa840581 16test_set_port SVNSERVE_PORT
b9c85187 17
36f5b1f0 18svn >/dev/null 2>&1
4b832e81 19if test $? -ne 1
36f5b1f0 20then
78109771
TZ
21 skip_all='skipping git svn tests, svn not found'
22 test_done
36f5b1f0
EW
23fi
24
25svnrepo=$PWD/svnrepo
cdf3ec01 26export svnrepo
da083d68
ER
27svnconf=$PWD/svnconf
28export svnconf
36f5b1f0 29
94221d22 30perl -w -e "
c6d499a8
EW
31use SVN::Core;
32use SVN::Repos;
33\$SVN::Core::VERSION gt '1.1.0' or exit(42);
cdf3ec01 34system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
38434f2e 35" >&3 2>&4
c6d499a8
EW
36x=$?
37if test $x -ne 0
dc62e25c 38then
c6d499a8 39 if test $x -eq 42; then
e8344e86 40 skip_all='Perl SVN libraries must be >= 1.1.0'
e66191f4 41 elif test $x -eq 41; then
e8344e86 42 skip_all='svnadmin failed to create fsfs repository'
c6d499a8 43 else
e8344e86 44 skip_all='Perl SVN libraries not found or unusable'
c6d499a8 45 fi
c6d499a8 46 test_done
dc62e25c
EW
47fi
48
2edb9c5c 49rawsvnrepo="$svnrepo"
e1516119 50svnrepo="file://$svnrepo"
36f5b1f0 51
7b3fab87 52poke() {
0e496492 53 test-tool chmtime +1 "$1"
7b3fab87 54}
29633bb9 55
da083d68
ER
56# We need this, because we should pass empty configuration directory to
57# the 'svn commit' to avoid automated property changes and other stuff
58# that could be set from user's configuration files in ~/.subversion.
59svn_cmd () {
60 [ -d "$svnconf" ] || mkdir "$svnconf"
61 orig_svncmd="$1"; shift
62 if [ -z "$orig_svncmd" ]; then
63 svn
64 return
65 fi
66 svn "$orig_svncmd" --config-dir "$svnconf" "$@"
67}
68
a8a5d251
EW
69maybe_start_httpd () {
70 loc=${1-svn}
71
72 test_tristate GIT_SVN_TEST_HTTPD
73 case $GIT_SVN_TEST_HTTPD in
74 true)
75 . "$TEST_DIRECTORY"/lib-httpd.sh
76 LIB_HTTPD_SVN="$loc"
77 start_httpd
78 ;;
79 *)
80 stop_httpd () {
81 : noop
82 }
83 ;;
84 esac
29633bb9 85}
060610c5
EW
86
87convert_to_rev_db () {
94221d22 88 perl -w -- - "$@" <<\EOF
060610c5 89use strict;
b978403a 90@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
060610c5
EW
91open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
92open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
93my $size = (stat($rd))[7];
94($size % 24) == 0 or die "Inconsistent size: $size";
95while (sysread($rd, my $buf, 24) == 24) {
96 my ($r, $c) = unpack('NH40', $buf);
97 my $offset = $r * 41;
98 seek $wr, 0, 2 or die $!;
99 my $pos = tell $wr;
100 if ($pos < $offset) {
101 for (1 .. (($offset - $pos) / 41)) {
102 print $wr (('0' x 40),"\n") or die $!;
103 }
104 }
105 seek $wr, $offset, 0 or die $!;
106 print $wr $c,"\n" or die $!;
107}
108close $wr or die $!;
109close $rd or die $!;
110EOF
111}
dd9da51f
AB
112
113require_svnserve () {
bf9d7df9
TZ
114 test_tristate GIT_TEST_SVNSERVE
115 if ! test "$GIT_TEST_SVNSERVE" = true
78109771 116 then
bf9d7df9 117 skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
78109771
TZ
118 test_done
119 fi
dd9da51f
AB
120}
121
122start_svnserve () {
78109771
TZ
123 svnserve --listen-port $SVNSERVE_PORT \
124 --root "$rawsvnrepo" \
125 --listen-once \
126 --listen-host 127.0.0.1 &
dd9da51f
AB
127}
128
3df0d26c
EW
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}