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