]> git.scottworley.com Git - pinch/blob - tests/lib/test-setup.sh
Release 3.0.9
[pinch] / tests / lib / test-setup.sh
1 set -e
2
3 export BACKOFF_MAX_TIME=0
4
5 export GIT_AUTHOR_NAME=automation
6 export GIT_COMMITTER_NAME=automation
7 export GIT_AUTHOR_EMAIL=auto@mati.on
8 export GIT_COMMITTER_EMAIL=auto@mati.on
9
10 cache_dir=$(mktemp -d)
11 data_dir=$(mktemp -d)
12 export XDG_CACHE_HOME=$cache_dir
13 export XDG_DATA_HOME=$data_dir
14
15 nix_store=$(mktemp -d)
16 nix_state=$(mktemp -d)
17 export NIX_STORE_DIR=$nix_store
18 export NIX_STATE_DIR=$nix_state
19
20 foo_setup() {
21
22 repo_dir="`mktemp -d`"
23 repo="$repo_dir/repo"
24 git -c init.defaultBranch=master init "$repo"
25 (
26 cd "$repo"
27 echo Contents > test-file
28 git add test-file
29 git commit -m 'Commit message'
30 )
31
32 conf="`mktemp`"
33 cat > "$conf" <<EOF
34 [foo]
35 type = git
36 git_repo = file://$repo
37 git_ref = master
38 EOF
39
40 }
41
42 test_cleanup() {
43 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
44 if [ "$conf" ];then rm "$conf"; fi
45 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
46 if [ "$data_dir" ];then rm -rf "$data_dir"; fi
47 if [ "$nix_store" ];then rm -rf "$nix_store"; fi
48 if [ "$nix_state" ];then rm -rf "$nix_state"; fi
49 }
50
51 trap test_cleanup EXIT INT TERM