Run each test in a clean directory
This commit is contained in:
23
test/runner
23
test/runner
@@ -12,15 +12,38 @@ try() {
|
||||
|
||||
setUp() {
|
||||
export TMPDIR="$PWD/.generated"
|
||||
export-repo-root
|
||||
move-to-working-directory
|
||||
}
|
||||
|
||||
tearDown() {
|
||||
[ "${_shunit_test_:=}" = '' ] && return 0
|
||||
|
||||
clean-up-working-directory
|
||||
|
||||
if [ "${__shunit_testSuccess:?}" != 0 ]; then
|
||||
output-outputs
|
||||
fi
|
||||
}
|
||||
|
||||
export-repo-root() {
|
||||
export REPO_ROOT="$PWD"
|
||||
while ! [[ -d $REPO_ROOT/.git ]]; do
|
||||
export REPO_ROOT=$(dirname $REPO_ROOT)
|
||||
done
|
||||
}
|
||||
|
||||
move-to-working-directory() {
|
||||
original_dir="$PWD"
|
||||
working_dir=$(mktemp -d)
|
||||
cd $working_dir
|
||||
}
|
||||
|
||||
clean-up-working-directory() {
|
||||
cd $original_dir
|
||||
rm -rf $working_dir
|
||||
}
|
||||
|
||||
output-outputs() {
|
||||
(
|
||||
bold '*******Test failed********'
|
||||
|
||||
Reference in New Issue
Block a user