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