specs/test_cli.sh
southerntofu 24bfd29c0f 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
2022-02-20 20:31:33 +01:00

42 lines
956 B
Bash
Executable File

#! /bin/bash
# Test me with: ./test_cli.sh PATH/TO/PROGRAM
SCRIPTDIR="$(dirname "$0")"
ORIGDIR="$(pwd)"
cd "$SCRIPTDIR"
export FORGEHOOK="$(pwd)/tests/mock-forgehook.sh"
source tests/helper.bash
if [ -z "$1" ]; then
output="$(findBin ../cli)"
if [ $? -eq 0 ]; then
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
FIND_WHCK="$output"
else
# Some warnings, print but use result from last line
echo "$output" | head -n -1
FIND_WHCK="$(echo "$output" | tail -n 1)"
fi
else
echo "ERROR: Could not find webhook validation program. Output:"
echo "$output"
exit 1
fi
# cli script needs to be executed to get absolute path to the program
export WHCK="$("$FIND_WHCK")"
else
if WHCK="$(realpath "$ORIGDIR"/"$1")"; then
export WHCK
else
export WHCK="$(realpath "$1")"
fi
fi
bats tests/cli/*.bats
cd "$ORIGDIR"