2022-02-20 19:31:33 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
# If you give first argument it will be a path to already cloned whck
|
|
|
|
|
2022-02-23 22:38:02 +00:00
|
|
|
function testOrError() {
|
|
|
|
message="$1"
|
|
|
|
shift
|
|
|
|
bin="$1"
|
|
|
|
shift
|
|
|
|
output="$("$bin" "$@" 2>&1)"
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "FAILURE: "$message""
|
|
|
|
echo "$output" | sed 's/^/ /g'
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
echo "SUCCESS: "$message""
|
|
|
|
}
|
|
|
|
|
2022-02-20 23:39:21 +00:00
|
|
|
# TODO: save exit codes of various tests so we can know how many failed
|
2022-02-20 19:31:33 +00:00
|
|
|
function testVariousScenarios() {
|
|
|
|
echo "Running various tests from "$(pwd)""
|
2022-02-23 22:38:02 +00:00
|
|
|
testOrError "bin/test.sh running from repo" bin/test.sh
|
2022-02-23 22:51:23 +00:00
|
|
|
cd specs
|
2022-02-23 22:38:02 +00:00
|
|
|
testOrError "forgecheck/test.sh with implicit ../bin/cli" forgecheck/test.sh
|
|
|
|
testOrError "forgecheck/test.sh with explicit result from ../bin/cli" forgecheck/test.sh "$(../bin/cli)"
|
2022-02-23 22:51:23 +00:00
|
|
|
testOrError "test.sh called from specs submodule" ../bin/test.sh
|
2022-02-23 22:38:02 +00:00
|
|
|
cd forgecheck
|
2022-02-23 22:51:23 +00:00
|
|
|
testOrError "bin/test.sh from specs/forgecheck folder" ../../bin/test.sh
|
|
|
|
testOrError "forgecheck/test.sh from specs/forgecheck folder with implicit ../../bin/cli" ./test.sh
|
|
|
|
testOrError "forgecheck/test.sh from specs/forgecheck folder with explicit result from ../../bin.cli" ./test.sh "$(../../bin/cli)"
|
2022-02-20 19:31:33 +00:00
|
|
|
cd tests
|
2022-02-23 22:51:23 +00:00
|
|
|
testOrError "bin/test.sh from specs/forgecheck/tests" ../../../bin/test.sh
|
|
|
|
testOrError "forgecheck/test.sh from specs/forgecheck/tests" ../test.sh
|
|
|
|
testOrError "forgecheck/test.sh from specs/forgehook/tests folder with explicit result from ../../../bin/cli" ../test.sh "$(../../../bin/cli)"
|
2022-02-20 19:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ORIGDIR="$(pwd)"
|
|
|
|
if [ -z "$1" ]; then
|
2022-02-20 20:48:05 +00:00
|
|
|
# When no explicit dir, try ./ first, otherwise make a temporary dir
|
|
|
|
if [ -x bin/cli ]; then
|
|
|
|
testVariousScenarios
|
2022-02-20 23:39:21 +00:00
|
|
|
elif [ -x ../bin/cli ]; then
|
|
|
|
cd ..
|
|
|
|
testVariousScenarios
|
2022-02-23 22:38:02 +00:00
|
|
|
elif [ -x ../../bin/cli ]; then
|
|
|
|
cd ../..
|
|
|
|
testVariousScenarios
|
2022-02-22 17:59:34 +00:00
|
|
|
elif [ -x whck/bin/cli ]; then
|
|
|
|
cd whck
|
|
|
|
testVariousScenarios
|
2022-02-22 16:50:53 +00:00
|
|
|
elif [ -x ../whck/bin/cli ]; then
|
|
|
|
cd ../whck
|
|
|
|
testVariousScenarios
|
2022-02-20 20:48:05 +00:00
|
|
|
else
|
|
|
|
TMPDIR="$(mktemp -d)"
|
|
|
|
cd "$TMPDIR"
|
|
|
|
git clone --recursive https://tildegit.org/forge/whck
|
|
|
|
cd whck
|
|
|
|
testVariousScenarios
|
2022-02-20 23:39:21 +00:00
|
|
|
cd "$ORIGDIR"
|
2022-02-20 20:48:05 +00:00
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
fi
|
2022-02-20 19:31:33 +00:00
|
|
|
else
|
|
|
|
if [ ! -d "$1" ]; then
|
|
|
|
echo "Wrong repo: "$1""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd "$1"
|
|
|
|
testVariousScenarios
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$ORIGDIR"
|