Add test_tests.sh which runs tests from various setups

Checks that absolute and relative links work
Fix an error in test_cli.sh which produced the error:
ERROR test_cli.sh failed from spec/tests folder with implicit ../../cli
This commit is contained in:
southerntofu 2022-02-20 20:31:33 +01:00
parent 9b18c0e162
commit 24bfd29c0f
2 changed files with 36 additions and 1 deletions

View File

@ -12,7 +12,7 @@ export FORGEHOOK="$(pwd)/tests/mock-forgehook.sh"
source tests/helper.bash
if [ -z "$1" ]; then
output="$(findBin "$SCRIPTDIR"/../cli)"
output="$(findBin ../cli)"
if [ $? -eq 0 ]; then
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
FIND_WHCK="$output"

35
test_tests.sh Executable file
View File

@ -0,0 +1,35 @@
#! /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 "$(../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 "$(../../cli)" || echo "ERROR test_cli.sh failed from spec/tests folder with explicit result from ../../cli"
}
ORIGDIR="$(pwd)"
if [ -z "$1" ]; then
TMPDIR="$(mktemp -d)"
cd "$TMPDIR"
git clone --recursive https://tildegit.org/forge/whck
cd whck
testVariousScenarios
rm -rf "$TMPDIR"
else
if [ ! -d "$1" ]; then
echo "Wrong repo: "$1""
exit 1
fi
cd "$1"
testVariousScenarios
fi
cd "$ORIGDIR"