]> git.scottworley.com Git - pinch/blob - tests/lib/test-setup.sh
f3eb661a175ff2b588f0aed2e4dfed6e1874e6e5
[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 export XDG_CACHE_HOME=$cache_dir
12
13 nix_store=$(mktemp -d)
14 nix_state=$(mktemp -d)
15 export NIX_STORE_DIR=$nix_store
16 export NIX_STATE_DIR=$nix_state
17
18 foo_setup() {
19
20 repo_dir="`mktemp -d`"
21 repo="$repo_dir/repo"
22 git -c init.defaultBranch=master init "$repo"
23 (
24 cd "$repo"
25 echo Contents > test-file
26 git add test-file
27 git commit -m 'Commit message'
28 )
29
30 conf="`mktemp`"
31 cat > "$conf" <<EOF
32 [foo]
33 type = git
34 git_repo = file://$repo
35 git_ref = master
36 EOF
37
38 }
39
40 test_cleanup() {
41 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
42 if [ "$conf" ];then rm "$conf"; fi
43 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
44 if [ "$nix_store" ];then rm -rf "$nix_store"; fi
45 if [ "$nix_state" ];then rm -rf "$nix_state"; fi
46 }
47
48 trap test_cleanup EXIT INT TERM