git-p4: fix typos
[git/gitster.git] / t / lib-git-svn.sh
blobea28971e8ee6abfcd3c0394c6d8b143c75ac12dd
1 if test -z "$TEST_FAILS_SANITIZE_LEAK"
2 then
3 TEST_PASSES_SANITIZE_LEAK=true
4 fi
5 . ./test-lib.sh
7 if test -n "$NO_SVN_TESTS"
8 then
9 skip_all='skipping git svn tests, NO_SVN_TESTS defined'
10 test_done
12 if ! test_have_prereq PERL; then
13 skip_all='skipping git svn tests, perl not available'
14 test_done
17 GIT_DIR=$PWD/.git
18 GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
19 SVN_TREE=$GIT_SVN_DIR/svn-tree
20 test_set_port SVNSERVE_PORT
22 svn >/dev/null 2>&1
23 if test $? -ne 1
24 then
25 skip_all='skipping git svn tests, svn not found'
26 test_done
29 svnrepo=$PWD/svnrepo
30 export svnrepo
31 svnconf=$PWD/svnconf
32 export svnconf
34 perl -w -e "
35 use SVN::Core;
36 use SVN::Repos;
37 \$SVN::Core::VERSION gt '1.1.0' or exit(42);
38 system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
39 " >&3 2>&4
40 x=$?
41 if test $x -ne 0
42 then
43 if test $x -eq 42; then
44 skip_all='Perl SVN libraries must be >= 1.1.0'
45 elif test $x -eq 41; then
46 skip_all='svnadmin failed to create fsfs repository'
47 else
48 skip_all='Perl SVN libraries not found or unusable'
50 test_done
53 rawsvnrepo="$svnrepo"
54 svnrepo="file://$svnrepo"
56 poke() {
57 test-tool chmtime +1 "$1"
60 # We need this, because we should pass empty configuration directory to
61 # the 'svn commit' to avoid automated property changes and other stuff
62 # that could be set from user's configuration files in ~/.subversion.
63 svn_cmd () {
64 [ -d "$svnconf" ] || mkdir "$svnconf"
65 orig_svncmd="$1"; shift
66 if [ -z "$orig_svncmd" ]; then
67 svn
68 return
70 svn "$orig_svncmd" --config-dir "$svnconf" "$@"
73 maybe_start_httpd () {
74 loc=${1-svn}
76 if test_bool_env GIT_TEST_SVN_HTTPD false
77 then
78 . "$TEST_DIRECTORY"/lib-httpd.sh
79 LIB_HTTPD_SVN="$loc"
80 start_httpd
84 convert_to_rev_db () {
85 perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF
86 use strict;
87 my $oidlen = shift;
88 @ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
89 my $record_size = $oidlen + 4;
90 my $hexlen = $oidlen * 2;
91 open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
92 open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
93 my $size = (stat($rd))[7];
94 ($size % $record_size) == 0 or die "Inconsistent size: $size";
95 while (sysread($rd, my $buf, $record_size) == $record_size) {
96 my ($r, $c) = unpack("NH$hexlen", $buf);
97 my $offset = $r * ($hexlen + 1);
98 seek $wr, 0, 2 or die $!;
99 my $pos = tell $wr;
100 if ($pos < $offset) {
101 for (1 .. (($offset - $pos) / ($hexlen + 1))) {
102 print $wr (('0' x $hexlen),"\n") or die $!;
105 seek $wr, $offset, 0 or die $!;
106 print $wr $c,"\n" or die $!;
108 close $wr or die $!;
109 close $rd or die $!;
113 require_svnserve () {
114 if ! test_bool_env GIT_TEST_SVNSERVE false
115 then
116 skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
117 test_done
121 start_svnserve () {
122 svnserve --listen-port $SVNSERVE_PORT \
123 --root "$rawsvnrepo" \
124 --listen-once \
125 --listen-host 127.0.0.1 &
128 prepare_utf8_locale () {
129 if test -z "$GIT_TEST_UTF8_LOCALE"
130 then
131 case "${LC_ALL:-$LANG}" in
132 *.[Uu][Tt][Ff]8 | *.[Uu][Tt][Ff]-8)
133 GIT_TEST_UTF8_LOCALE="${LC_ALL:-$LANG}"
136 GIT_TEST_UTF8_LOCALE=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
141 esac
143 if test -n "$GIT_TEST_UTF8_LOCALE"
144 then
145 test_set_prereq UTF8
146 else
147 say "# UTF-8 locale not available, some tests are skipped"