]> git.scottworley.com Git - pinch/blame - tests/lib/test-setup.sh
Handle 0 terminal width
[pinch] / tests / lib / test-setup.sh
CommitLineData
a2290fb1
SW
1set -e
2
78c89e6e
SW
3cache_dir=$(mktemp -d)
4export XDG_CACHE_HOME=$cache_dir
5
a2290fb1
SW
6foo_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]
21git_repo = file://$repo
22git_ref = master
23EOF
24
25}
26
d9a1088a
SW
27test_cleanup() {
28 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
29 if [ "$conf" ];then rm "$conf"; fi
78c89e6e 30 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
a2290fb1 31}
d9a1088a
SW
32
33trap test_cleanup EXIT INT TERM