]>
Commit | Line | Data |
---|---|---|
60d02ccc EW |
1 | . ./test-lib.sh |
2 | ||
3 | if test -n "$NO_SVN_TESTS" | |
36f5b1f0 | 4 | then |
fadb5156 | 5 | skip_all='skipping git svn tests, NO_SVN_TESTS defined' |
60d02ccc | 6 | test_done |
36f5b1f0 | 7 | fi |
1b19ccd2 | 8 | if ! test_have_prereq PERL; then |
fadb5156 | 9 | skip_all='skipping git svn tests, perl not available' |
1b19ccd2 JK |
10 | test_done |
11 | fi | |
36f5b1f0 | 12 | |
b9c85187 | 13 | GIT_DIR=$PWD/.git |
6f5748e1 | 14 | GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn |
b9c85187 EW |
15 | SVN_TREE=$GIT_SVN_DIR/svn-tree |
16 | ||
36f5b1f0 | 17 | svn >/dev/null 2>&1 |
4b832e81 | 18 | if test $? -ne 1 |
36f5b1f0 | 19 | then |
78109771 TZ |
20 | skip_all='skipping git svn tests, svn not found' |
21 | test_done | |
36f5b1f0 EW |
22 | fi |
23 | ||
24 | svnrepo=$PWD/svnrepo | |
cdf3ec01 | 25 | export svnrepo |
da083d68 ER |
26 | svnconf=$PWD/svnconf |
27 | export svnconf | |
36f5b1f0 | 28 | |
94221d22 | 29 | perl -w -e " |
c6d499a8 EW |
30 | use SVN::Core; |
31 | use SVN::Repos; | |
32 | \$SVN::Core::VERSION gt '1.1.0' or exit(42); | |
cdf3ec01 | 33 | system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41); |
38434f2e | 34 | " >&3 2>&4 |
c6d499a8 EW |
35 | x=$? |
36 | if test $x -ne 0 | |
dc62e25c | 37 | then |
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 |
46 | fi |
47 | ||
2edb9c5c | 48 | rawsvnrepo="$svnrepo" |
e1516119 | 49 | svnrepo="file://$svnrepo" |
36f5b1f0 | 50 | |
7b3fab87 | 51 | poke() { |
0e496492 | 52 | test-tool 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. | |
58 | svn_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 |
68 | maybe_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 | |
86 | convert_to_rev_db () { | |
94221d22 | 87 | perl -w -- - "$@" <<\EOF |
060610c5 | 88 | use strict; |
b978403a | 89 | @ARGV == 2 or die "usage: convert_to_rev_db <input> <output>"; |
060610c5 EW |
90 | open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]"; |
91 | open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]"; | |
92 | my $size = (stat($rd))[7]; | |
93 | ($size % 24) == 0 or die "Inconsistent size: $size"; | |
94 | while (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 | } | |
107 | close $wr or die $!; | |
108 | close $rd or die $!; | |
109 | EOF | |
110 | } | |
dd9da51f AB |
111 | |
112 | require_svnserve () { | |
bf9d7df9 TZ |
113 | test_tristate GIT_TEST_SVNSERVE |
114 | if ! test "$GIT_TEST_SVNSERVE" = true | |
78109771 | 115 | then |
bf9d7df9 | 116 | skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)' |
78109771 TZ |
117 | test_done |
118 | fi | |
dd9da51f AB |
119 | } |
120 | ||
121 | start_svnserve () { | |
bf9d7df9 | 122 | SVNSERVE_PORT=${SVNSERVE_PORT-${this_test#t}} |
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 |
129 | prepare_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 | } |