Run each test in a clean directory
This commit is contained in:
parent
4f70443bda
commit
f679a866f1
23
test/runner
23
test/runner
@ -12,15 +12,38 @@ try() {
|
|||||||
|
|
||||||
setUp() {
|
setUp() {
|
||||||
export TMPDIR="$PWD/.generated"
|
export TMPDIR="$PWD/.generated"
|
||||||
|
export-repo-root
|
||||||
|
move-to-working-directory
|
||||||
}
|
}
|
||||||
|
|
||||||
tearDown() {
|
tearDown() {
|
||||||
[ "${_shunit_test_:=}" = '' ] && return 0
|
[ "${_shunit_test_:=}" = '' ] && return 0
|
||||||
|
|
||||||
|
clean-up-working-directory
|
||||||
|
|
||||||
if [ "${__shunit_testSuccess:?}" != 0 ]; then
|
if [ "${__shunit_testSuccess:?}" != 0 ]; then
|
||||||
output-outputs
|
output-outputs
|
||||||
fi
|
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() {
|
output-outputs() {
|
||||||
(
|
(
|
||||||
bold '*******Test failed********'
|
bold '*******Test failed********'
|
||||||
|
@ -4,7 +4,7 @@ testUsageIsShownWhenNoCommandIsSpecified() {
|
|||||||
echo '
|
echo '
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
' > go
|
' > go
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go
|
try ./go
|
||||||
@ -16,7 +16,7 @@ testHelpSubcommandCannotBeOverridden() {
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
⚡️help() { echo "ah hah hah" ; }
|
⚡️help() { echo "ah hah hah" ; }
|
||||||
' > go
|
' > go
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go help
|
try ./go help
|
||||||
@ -28,7 +28,7 @@ testHelpIncludesInvocationInstructions() {
|
|||||||
echo '
|
echo '
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
' > $SCRIPT_NAME
|
' > $SCRIPT_NAME
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> $SCRIPT_NAME
|
echo "source $REPO_ROOT/⚡️" >> $SCRIPT_NAME
|
||||||
chmod +x $SCRIPT_NAME
|
chmod +x $SCRIPT_NAME
|
||||||
|
|
||||||
try ./$SCRIPT_NAME help
|
try ./$SCRIPT_NAME help
|
||||||
@ -43,7 +43,7 @@ testHelpListsAllAvailableLightningCommands() {
|
|||||||
⚡️baz() { echo "ah hah hah" ; }
|
⚡️baz() { echo "ah hah hah" ; }
|
||||||
⚡️potato() { echo "ah hah hah" ; }
|
⚡️potato() { echo "ah hah hah" ; }
|
||||||
' > go
|
' > go
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go help
|
try ./go help
|
||||||
@ -64,7 +64,7 @@ testHelpLinesFromDefinedCommandsAreShown() {
|
|||||||
}
|
}
|
||||||
' > go
|
' > go
|
||||||
|
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go
|
try ./go
|
||||||
@ -78,7 +78,7 @@ testHelpDoesNotExecuteFunctionsWithNoHelpLine() {
|
|||||||
⚡️hello() { echo "Hello, World!" ; }
|
⚡️hello() { echo "Hello, World!" ; }
|
||||||
' > go
|
' > go
|
||||||
|
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go
|
try ./go
|
||||||
@ -92,7 +92,7 @@ testLightningShouldNotBeIncludedInSubcommandNames() {
|
|||||||
⚡️hello() { echo "Hello, World!" ; }
|
⚡️hello() { echo "Hello, World!" ; }
|
||||||
' > go
|
' > go
|
||||||
|
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go
|
try ./go
|
||||||
|
@ -7,7 +7,7 @@ testDefiningALightningFunctionWorks() {
|
|||||||
⚡️hello() { echo "Hello, World!" ; }
|
⚡️hello() { echo "Hello, World!" ; }
|
||||||
' > go
|
' > go
|
||||||
|
|
||||||
echo "source $(dirname $BASH_SOURCE)/../⚡️" >> go
|
echo "source $REPO_ROOT/⚡️" >> go
|
||||||
chmod +x go
|
chmod +x go
|
||||||
|
|
||||||
try ./go hello
|
try ./go hello
|
||||||
|
Loading…
Reference in New Issue
Block a user