specs/test_tests.sh
southerntofu 9f17e49114 Move cli building script to bin/
Add convenience try for pwd as repo to test when calling test_tests.sh without arguments
2022-02-20 21:48:05 +01:00

41 lines
1.3 KiB
Bash
Executable File

#! /usr/bin/env bash
# If you give first argument it will be a path to already cloned whck
function testVariousScenarios() {
echo "Running various tests from "$(pwd)""
./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"
../test.sh || echo "ERROR test.sh failed called from spec submodule"
cd tests
../../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
else
TMPDIR="$(mktemp -d)"
cd "$TMPDIR"
git clone --recursive https://tildegit.org/forge/whck
cd whck
testVariousScenarios
rm -rf "$TMPDIR"
fi
else
if [ ! -d "$1" ]; then
echo "Wrong repo: "$1""
exit 1
fi
cd "$1"
testVariousScenarios
fi
cd "$ORIGDIR"