test setup: Prepare store directory before starting tests

This commit is contained in:
Matthias Beyer 2016-09-08 09:17:22 +02:00
parent 566c463383
commit 157f4e79aa

View file

@ -47,10 +47,16 @@ cat_entry() {
}
reset_store() {
rm -rf "${STORE}"/.git
rm -r "${STORE}"
}
call_test() {
prepare_store_directory || {
err "Preparing store directory failed"
exit 1
}
out "-- TESTING: '$1' --"
$1
result=$?
@ -63,6 +69,27 @@ call_test() {
success "-- SUCCESS: '$1' --"
}
__git() {
out "Calling git: $*"
git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $*
}
__git_commit() {
out "Calling git-commit: $*"
git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*"
}
prepare_store_directory() {
out "Preparing /tmp/store"
mkdir -p /tmp/store/ &&\
touch /tmp/store/.gitkeep &&\
__git init &&\
__git config --local user.email "imag@imag-pim.org" &&\
__git config --local user.name "Imag CI" &&\
__git add .gitkeep &&\
__git_commit 'Initial commit: .gitkeep'
}
invoke_tests() {
out "Invoking tests."
if [[ ! -z "$INVOKE_TEST" ]]; then