]> git.scottworley.com Git - pinch/blame - tests/lib/test-setup.sh
Start pulling release_name and git_revision out of SearchPath
[pinch] / tests / lib / test-setup.sh
CommitLineData
a2290fb1
SW
1set -e
2
1b48018c
SW
3export GIT_AUTHOR_NAME=automation
4export GIT_COMMITTER_NAME=automation
5export GIT_AUTHOR_EMAIL=auto@mati.on
6export GIT_COMMITTER_EMAIL=auto@mati.on
7
78c89e6e
SW
8cache_dir=$(mktemp -d)
9export XDG_CACHE_HOME=$cache_dir
10
4af9966c
SW
11nix_store=$(mktemp -d)
12nix_state=$(mktemp -d)
13export NIX_STORE_DIR=$nix_store
14export NIX_STATE_DIR=$nix_state
15
a2290fb1
SW
16foo_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]
7f4c3ace 31type = git
a2290fb1
SW
32git_repo = file://$repo
33git_ref = master
34EOF
35
36}
37
d9a1088a
SW
38test_cleanup() {
39 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
40 if [ "$conf" ];then rm "$conf"; fi
78c89e6e 41 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
4af9966c
SW
42 if [ "$nix_store" ];then rm -rf "$nix_store"; fi
43 if [ "$nix_state" ];then rm -rf "$nix_state"; fi
a2290fb1 44}
d9a1088a
SW
45
46trap test_cleanup EXIT INT TERM