remote-hg: add tests for special filenames
[git] / t / remote-helpers / test-versions
1 #!/bin/bash
2
3 ext=$1
4 git='/home/felipec/dev/git'
5
6 if [ $ext == 'hg' ]; then
7         versions=(1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6)
8         tests=test-{hg,hg-bidi,hg-hg-git}.t
9         ext_dir='/home/felipec/tmp/hg'
10 else
11         versions=(bzr-2.6b1 bzr-2.5.0 bzr-2.4.0 bzr-2.3.0 bzr-2.2.0 bzr-2.1.4 bzr-2.0.6)
12         tests=test-bzr.t
13         ext_dir='/home/felipec/tmp/bzr'
14 fi
15
16 use_lib() {
17         export PYTHONPATH=$1
18         export PATH=$1:$PATH
19 }
20
21 # prepare checkouts
22 for version in "${versions[@]}"
23 do
24         dir=/tmp/$ext/$version &&
25         test -d $dir && continue
26
27         echo "preparing $version checkout" &&
28         (
29                 git clone -n -q --shared $ext_dir $dir &&
30                 cd $dir &&
31                 git checkout -q $version &&
32                 test $ext == 'hg' &&
33                         printf 'version = "%s"\n' $version > mercurial/__version__.py &&
34                 # make local >& /dev/null
35                 python setup.py build_py -c -d . build_ext -i build_scripts >& /dev/null
36         )
37 done
38
39 check_commit() {
40         local ok=1 version dir tmpdir
41
42         rm -f /tmp/error
43
44         for version in "${versions[@]}"
45         do
46                 (
47                         use_lib /tmp/$ext/$version &&
48                         dir=$PWD/contrib/remote-helpers &&
49                         tmpdir=$(mktemp -d) &&
50                         export TEST_OUTPUT_DIRECTORY=$tmpdir &&
51                         export TEST_DIRECTORY=$PWD/t &&
52                         export PATH=$PWD:$PATH &&
53                         cd t &&
54                         eval prove -v $dir/$tests > $dir/output || ok=0
55                         rm -rf $tmpdir
56                         let ok && echo "$version: ok" || echo "$version: not ok"
57                         let ok || { cat $dir/output && touch /tmp/error ; }
58                 ) &
59         done
60         wait
61         test -f /tmp/error && return 1 || return 0
62 }
63
64 check_revlist() {
65         git rev-list --reverse $1 | while read commit
66         do
67                 git checkout -q $commit &&
68                 git log -1 --oneline &&
69                 check_commit || return 1
70         done
71 }
72
73 ret=1 &&
74 cd $git &&
75
76 make -C contrib/remote-helpers links &&
77
78 shift
79 if test -z $1
80 then
81         check_commit && ret=0
82 else
83         old=$(sed -e 's/^ref: refs.heads.//' .git/HEAD) &&
84         check_revlist $1 && ret=0
85         git checkout -q $old
86 fi
87
88 exit $ret