summaryrefslogtreecommitdiff
path: root/test/hg-ssh
blob: 27ad6106d28ecdd94bfd7239496a6f17de3d2b3b (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
43
44
45
46
47
48
49
50
51
52
#!/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
  if [ $# -ge 1 ]; then
    args=$1 ; shift
  fi
  hg clone "$url"
  if [ $? -ne 0 ]; then
    echo "Failed to hg clone $url"
    exit 1
  fi
  base=$(basename "$url")
  test -d "$base" || exit 1
  rm -rf "$base"
  test -d "$base" && exit 1
}

HGPROJ=${HGPROJ:-test-project}

list="
ssh://$USER@hg.sv.gnu.org/${HGPROJ}
ssh://$USER@hg.sv.nongnu.org/${HGPROJ}
ssh://$USER@hg.savannah.gnu.org/${HGPROJ}
ssh://$USER@hg.savannah.nongnu.org/${HGPROJ}
"

for url in $list; do
  testit "$url"
done

exit 0