]> arthur.barton.de Git - bup.git/blob - t/configure-sampledata
Use t/sampledata, not make install, for tests
[bup.git] / t / configure-sampledata
1 #!/usr/bin/env bash
2
3 set -o pipefail
4
5 # NOTE: any relevant changes to var/ must be accompanied by an
6 # increment to the revision.
7
8 revision=1
9 readonly revision
10
11 top="$(pwd)" || exit $?
12
13 usage()
14 {
15     echo 'Usage: t/configure-sampledata [--setup | --clean | --revision]'
16 }
17
18 if test "$#" -ne 1; then
19     usage 1>&2; exit 1
20 fi
21
22 clean()
23 (
24     cd t/sampledata || exit $?
25     if test -e var; then rm -r var || exit $?; fi
26     # Remove legacy content (before everything moved to var/).
27     # test -e is false for dangling symlinks.
28     if test -h b -o -e b; then rm b || exit $?; fi
29     if test -h c -o -e c; then rm c || exit $?; fi
30     if test -h abs-symlink -o -e abs-symlink; then
31         rm abs-symlink || exit $?
32     fi
33 )
34
35 case "$1" in
36     --setup)
37         (
38             clean
39             mkdir -p t/sampledata/var/rev || exit $?
40             cd t/sampledata/var || exit $?
41             ln -sf a b || exit $?
42             ln -sf b c || exit $?
43             ln -sf "$(pwd)/abs-symlink-target" abs-symlink || exit $?
44             mkdir -p cmd doc lib/bup || exit $?
45             cp -a "$top"/cmd/*.py cmd/ || exit $?
46             cp -a "$top"/Documentation/*.md doc/ || exit $?
47             cp -a "$top"/lib/bup/*.py lib/bup || exit $?
48             # The "v" ensures that if "configure-sampledata
49             # --revision" and/or the setup above fails somehow,
50             # callers like make will be looking for a file that won't
51             # exist.
52             touch rev/v$revision || exit $?
53         ) || exit $?
54         ;;
55     --clean)
56         clean
57         ;;
58     --revision)
59         echo "$revision" || exit $?
60         ;;
61     *)
62         usage 1>&2; exit 1
63         ;;
64 esac