]> git.scottworley.com Git - pinch/blobdiff - tests/lib/test-setup.sh
Un-deprecate: This continues being useful
[pinch] / tests / lib / test-setup.sh
index 12cf525878a65dfbea6b14f095192098dc4d7c7d..e4260f4646f85a73fdca62b1c81a5e6d7579ed93 100644 (file)
@@ -1,10 +1,27 @@
 set -e
 
+export BACKOFF_MAX_TIME=0
+
+export GIT_AUTHOR_NAME=automation
+export GIT_COMMITTER_NAME=automation
+export GIT_AUTHOR_EMAIL=auto@mati.on
+export GIT_COMMITTER_EMAIL=auto@mati.on
+
+cache_dir=$(mktemp -d)
+data_dir=$(mktemp -d)
+export XDG_CACHE_HOME=$cache_dir
+export XDG_DATA_HOME=$data_dir
+
+nix_store=$(mktemp -d)
+nix_state=$(mktemp -d)
+export NIX_STORE_DIR=$nix_store
+export NIX_STATE_DIR=$nix_state
+
 foo_setup() {
 
   repo_dir="`mktemp -d`"
   repo="$repo_dir/repo"
-  git init "$repo"
+  git -c init.defaultBranch=master init "$repo"
   (
     cd "$repo"
     echo Contents > test-file
@@ -15,12 +32,20 @@ foo_setup() {
   conf="`mktemp`"
   cat > "$conf" <<EOF
 [foo]
+type = git
 git_repo = file://$repo
 git_ref = master
 EOF
 
 }
 
-foo_cleanup() {
-  rm -rf "$repo_dir" "$conf"
+test_cleanup() {
+  if [ "$repo_dir"  ];then rm -rf "$repo_dir";  fi
+  if [ "$conf"      ];then rm     "$conf";      fi
+  if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
+  if [ "$data_dir"  ];then rm -rf "$data_dir";  fi
+  if [ "$nix_store" ];then rm -rf "$nix_store"; fi
+  if [ "$nix_state" ];then rm -rf "$nix_state"; fi
 }
+
+trap test_cleanup EXIT INT TERM