From 24bfd29c0ffe0fb6b132ff553c944ac41f858e30 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Sun, 20 Feb 2022 20:31:33 +0100 Subject: [PATCH] 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 --- test_cli.sh | 2 +- test_tests.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 test_tests.sh diff --git a/test_cli.sh b/test_cli.sh index 8fc2cae..1b178a6 100755 --- a/test_cli.sh +++ b/test_cli.sh @@ -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" diff --git a/test_tests.sh b/test_tests.sh new file mode 100755 index 0000000..705ec06 --- /dev/null +++ b/test_tests.sh @@ -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"