summaryrefslogtreecommitdiff
path: root/test/hg-rsync
blob: 24bbf98cb71dd93c7bef5dca7de6565c692b9939 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

# Copyright 2017 Bob Proulx <bob@proulx.com>
# You may freely use, modify and/or distribute this file.

# Ensure a standard behavior regardless of caller locale setting.
export LC_ALL=C

unset tmpdir
cleanup() {
  test -n "$tmpdir" && rm -rf "$tmpdir" && unset tmpdir
}
trap "cleanup" EXIT
trap "cleanup; trap - HUP; kill -HUP $$" HUP
trap "cleanup; trap - INT; kill -INT $$" INT
trap "cleanup; trap - QUIT; kill -QUIT $$" QUIT
trap "cleanup; trap - TERM; kill -TERM $$" TERM

tmpdir=$(mktemp -d -t "sv-test.XXXXXXXX") || exit 1

cd "$tmpdir" || exit 1

testit() {
  url=$1 ; shift
  rsync "$url" > out
  if [ $? -ne 0 ]; then
    echo "Failed: rsync $url"
    exit 1
  fi
  test -s out || exit 1
  rm -f out
  test -s out && exit 1
}

HGPROJ=${HGPROJ:-test-project}

testit rsync://hg.savannah.gnu.org/hg/${HGPROJ}
testit rsync://hg.savannah.nongnu.org/hg/${HGPROJ}
testit rsync://hg.sv.gnu.org/hg/${HGPROJ}
testit rsync://hg.sv.nongnu.org/hg/${HGPROJ}

exit 0