Merge branch 'lt/gpg-show-long-key-in-signature-verification'
[git/git-svn.git] / t / lib-git-svn.sh
blob688313ed5cc40e22b2412c57f98df06e4f3ac0ea
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
17 svn >/dev/null 2>&1
18 if test $? -ne 1
19 then
20 skip_all='skipping git svn tests, svn not found'
21 test_done
24 svnrepo=$PWD/svnrepo
25 export svnrepo
26 svnconf=$PWD/svnconf
27 export svnconf
29 perl -w -e "
30 use SVN::Core;
31 use SVN::Repos;
32 \$SVN::Core::VERSION gt '1.1.0' or exit(42);
33 system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
34 " >&3 2>&4
35 x=$?
36 if test $x -ne 0
37 then
38 if test $x -eq 42; then
39 skip_all='Perl SVN libraries must be >= 1.1.0'
40 elif test $x -eq 41; then
41 skip_all='svnadmin failed to create fsfs repository'
42 else
43 skip_all='Perl SVN libraries not found or unusable'
45 test_done
48 rawsvnrepo="$svnrepo"
49 svnrepo="file://$svnrepo"
51 poke() {
52 test-chmtime +1 "$1"
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
65 svn "$orig_svncmd" --config-dir "$svnconf" "$@"
68 maybe_start_httpd () {
69 loc=${1-svn}
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
79 stop_httpd () {
80 : noop
83 esac
86 convert_to_rev_db () {
87 perl -w -- - "$@" <<\EOF
88 use strict;
89 @ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
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 $!;
104 seek $wr, $offset, 0 or die $!;
105 print $wr $c,"\n" or die $!;
107 close $wr or die $!;
108 close $rd or die $!;
112 require_svnserve () {
113 if test -z "$SVNSERVE_PORT"
114 then
115 skip_all='skipping svnserve test. (set $SVNSERVE_PORT to enable)'
116 test_done
120 start_svnserve () {
121 svnserve --listen-port $SVNSERVE_PORT \
122 --root "$rawsvnrepo" \
123 --listen-once \
124 --listen-host 127.0.0.1 &
127 prepare_a_utf8_locale () {
128 a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
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"