t1092: stress test 'git sparse-checkout set'
[git/debian.git] / t / lib-git-svn.sh
blob2fde2353fd38356548fd40e4808984618b0d9585
1 . ./test-lib.sh
3 if test -n "$NO_SVN_TESTS"
4 then
5 skip_all='skipping git svn tests, NO_SVN_TESTS defined'
6 test_done
7 fi
8 if ! test_have_prereq PERL; then
9 skip_all='skipping git svn tests, perl not available'
10 test_done
13 GIT_DIR=$PWD/.git
14 GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
15 SVN_TREE=$GIT_SVN_DIR/svn-tree
16 test_set_port SVNSERVE_PORT
18 svn >/dev/null 2>&1
19 if test $? -ne 1
20 then
21 skip_all='skipping git svn tests, svn not found'
22 test_done
25 svnrepo=$PWD/svnrepo
26 export svnrepo
27 svnconf=$PWD/svnconf
28 export svnconf
30 perl -w -e "
31 use SVN::Core;
32 use SVN::Repos;
33 \$SVN::Core::VERSION gt '1.1.0' or exit(42);
34 system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
35 " >&3 2>&4
36 x=$?
37 if test $x -ne 0
38 then
39 if test $x -eq 42; then
40 skip_all='Perl SVN libraries must be >= 1.1.0'
41 elif test $x -eq 41; then
42 skip_all='svnadmin failed to create fsfs repository'
43 else
44 skip_all='Perl SVN libraries not found or unusable'
46 test_done
49 rawsvnrepo="$svnrepo"
50 svnrepo="file://$svnrepo"
52 poke() {
53 test-tool chmtime +1 "$1"
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.
59 svn_cmd () {
60 [ -d "$svnconf" ] || mkdir "$svnconf"
61 orig_svncmd="$1"; shift
62 if [ -z "$orig_svncmd" ]; then
63 svn
64 return
66 svn "$orig_svncmd" --config-dir "$svnconf" "$@"
69 maybe_start_httpd () {
70 loc=${1-svn}
72 if test_bool_env GIT_TEST_SVN_HTTPD false
73 then
74 . "$TEST_DIRECTORY"/lib-httpd.sh
75 LIB_HTTPD_SVN="$loc"
76 start_httpd
80 convert_to_rev_db () {
81 perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF
82 use strict;
83 my $oidlen = shift;
84 @ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
85 my $record_size = $oidlen + 4;
86 my $hexlen = $oidlen * 2;
87 open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
88 open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
89 my $size = (stat($rd))[7];
90 ($size % $record_size) == 0 or die "Inconsistent size: $size";
91 while (sysread($rd, my $buf, $record_size) == $record_size) {
92 my ($r, $c) = unpack("NH$hexlen", $buf);
93 my $offset = $r * ($hexlen + 1);
94 seek $wr, 0, 2 or die $!;
95 my $pos = tell $wr;
96 if ($pos < $offset) {
97 for (1 .. (($offset - $pos) / ($hexlen + 1))) {
98 print $wr (('0' x $hexlen),"\n") or die $!;
101 seek $wr, $offset, 0 or die $!;
102 print $wr $c,"\n" or die $!;
104 close $wr or die $!;
105 close $rd or die $!;
109 require_svnserve () {
110 if ! test_bool_env GIT_TEST_SVNSERVE false
111 then
112 skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)'
113 test_done
117 start_svnserve () {
118 svnserve --listen-port $SVNSERVE_PORT \
119 --root "$rawsvnrepo" \
120 --listen-once \
121 --listen-host 127.0.0.1 &
124 prepare_utf8_locale () {
125 if test -z "$GIT_TEST_UTF8_LOCALE"
126 then
127 case "${LC_ALL:-$LANG}" in
128 *.[Uu][Tt][Ff]8 | *.[Uu][Tt][Ff]-8)
129 GIT_TEST_UTF8_LOCALE="${LC_ALL:-$LANG}"
132 GIT_TEST_UTF8_LOCALE=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
137 esac
139 if test -n "$GIT_TEST_UTF8_LOCALE"
140 then
141 test_set_prereq UTF8
142 else
143 say "# UTF-8 locale not available, some tests are skipped"