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