#! /usr/bin/env bash # If you give first argument it will be a path to already cloned endpoint # 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_web.sh || echo "ERROR test_web.sh failed with implicit ../bin/server" ./test_web.sh "$(../bin/server)" || echo "ERROR test_cli with explicit result from ../bin/server" ../bin/test.sh || echo "ERROR bin/test.sh failed called from spec submodule" cd tests ../../bin/test.sh || echo "ERROR bin/test.sh failed from spec/tests folder" ../test_web.sh || echo "ERROR test_web.sh failed from spec/tests folder with implicit ../../bin/server" ../test_web.sh "$(../../bin/server)" || echo "ERROR test_web.sh failed from spec/tests folder with explicit result from ../../bin/server" } ORIGDIR="$(pwd)" if [ -z "$1" ]; then # When no explicit dir, try ./ first, otherwise ../, otherwise make a temporary dir if [ -x bin/server ]; then testVariousScenarios elif [ -x ../bin/server ]; then cd .. testVariousScenarios else TMPDIR="$(mktemp -d)" cd "$TMPDIR" git clone --recursive https://tildegit.org/forge/endpoints.php cd endpoints.php 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"