]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-git-svn.sh
t/lib-git-svn: cleanup inconsistent tab/space usage
[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
EW
15SVN_TREE=$GIT_SVN_DIR/svn-tree
16
36f5b1f0 17svn >/dev/null 2>&1
4b832e81 18if test $? -ne 1
36f5b1f0 19then
78109771
TZ
20 skip_all='skipping git svn tests, svn not found'
21 test_done
36f5b1f0
EW
22fi
23
24svnrepo=$PWD/svnrepo
cdf3ec01 25export svnrepo
da083d68
ER
26svnconf=$PWD/svnconf
27export svnconf
36f5b1f0 28
94221d22 29perl -w -e "
c6d499a8
EW
30use SVN::Core;
31use SVN::Repos;
32\$SVN::Core::VERSION gt '1.1.0' or exit(42);
cdf3ec01 33system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
38434f2e 34" >&3 2>&4
c6d499a8
EW
35x=$?
36if test $x -ne 0
dc62e25c 37then
c6d499a8 38 if test $x -eq 42; then
e8344e86 39 skip_all='Perl SVN libraries must be >= 1.1.0'
e66191f4 40 elif test $x -eq 41; then
e8344e86 41 skip_all='svnadmin failed to create fsfs repository'
c6d499a8 42 else
e8344e86 43 skip_all='Perl SVN libraries not found or unusable'
c6d499a8 44 fi
c6d499a8 45 test_done
dc62e25c
EW
46fi
47
2edb9c5c 48rawsvnrepo="$svnrepo"
e1516119 49svnrepo="file://$svnrepo"
36f5b1f0 50
7b3fab87 51poke() {
56cf9806 52 test-chmtime +1 "$1"
7b3fab87 53}
29633bb9 54
da083d68
ER
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
a8a5d251
EW
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
29633bb9 84}
060610c5
EW
85
86convert_to_rev_db () {
94221d22 87 perl -w -- - "$@" <<\EOF
060610c5 88use strict;
b978403a 89@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
060610c5
EW
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}
dd9da51f
AB
111
112require_svnserve () {
78109771
TZ
113 if test -z "$SVNSERVE_PORT"
114 then
115 skip_all='skipping svnserve test. (set $SVNSERVE_PORT to enable)'
116 test_done
117 fi
dd9da51f
AB
118}
119
120start_svnserve () {
78109771
TZ
121 svnserve --listen-port $SVNSERVE_PORT \
122 --root "$rawsvnrepo" \
123 --listen-once \
124 --listen-host 127.0.0.1 &
dd9da51f
AB
125}
126
3df0d26c
EW
127prepare_a_utf8_locale () {
128 a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
129 p
130 q
131}')
132 if test -n "$a_utf8_locale"
133 then
134 test_set_prereq UTF8
135 else
136 say "# UTF-8 locale not available, some tests are skipped"
137 fi
138}