]> git.scottworley.com Git - pinch/blob - tests/lib/test-setup.sh
Use separate cache dir for test isolation
[pinch] / tests / lib / test-setup.sh
1 set -e
2
3 cache_dir=$(mktemp -d)
4 export XDG_CACHE_HOME=$cache_dir
5
6 foo_setup() {
7
8 repo_dir="`mktemp -d`"
9 repo="$repo_dir/repo"
10 git init "$repo"
11 (
12 cd "$repo"
13 echo Contents > test-file
14 git add test-file
15 git commit -m 'Commit message'
16 )
17
18 conf="`mktemp`"
19 cat > "$conf" <<EOF
20 [foo]
21 git_repo = file://$repo
22 git_ref = master
23 EOF
24
25 }
26
27 test_cleanup() {
28 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
29 if [ "$conf" ];then rm "$conf"; fi
30 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
31 }
32
33 trap test_cleanup EXIT INT TERM