specs/forgecheck/test_tests.sh

52 lines
1.6 KiB
Bash
Executable File

#! /usr/bin/env bash
# If you give first argument it will be a path to already cloned whck
# TODO: save exit codes of various tests so we can know how many failed
function testVariousScenarios() {
echo "Running various tests from "$(pwd)""
bin/test.sh || echo "ERROR running from repo"
cd spec
./test_cli.sh || echo "ERROR test_cli.sh failed with implicit ../cli"
./test_cli.sh "$(../bin/cli)" || echo "ERROR test_cli with explicit result from ../cli"
../bin/test.sh || echo "ERROR test.sh failed called from spec submodule"
cd tests
../../bin/test.sh || echo "ERROR test.sh failed from spec/tests folder"
../test_cli.sh || echo "ERROR test_cli.sh failed from spec/tests folder with implicit ../../cli"
../test_cli.sh "$(../../bin/cli)" || echo "ERROR test_cli.sh failed from spec/tests folder with explicit result from ../../cli"
}
ORIGDIR="$(pwd)"
if [ -z "$1" ]; then
# When no explicit dir, try ./ first, otherwise make a temporary dir
if [ -x bin/cli ]; then
testVariousScenarios
elif [ -x ../bin/cli ]; then
cd ..
testVariousScenarios
elif [ -x whck/bin/cli ]; then
cd whck
testVariousScenarios
elif [ -x ../whck/bin/cli ]; then
cd ../whck
testVariousScenarios
else
TMPDIR="$(mktemp -d)"
cd "$TMPDIR"
git clone --recursive https://tildegit.org/forge/whck
cd whck
testVariousScenarios
cd "$ORIGDIR"
rm -rf "$TMPDIR"
fi
else
if [ ! -d "$1" ]; then
echo "Wrong repo: "$1""
exit 1
fi
cd "$1"
testVariousScenarios
fi
cd "$ORIGDIR"