specs/test_web.sh

64 lines
1.8 KiB
Bash
Executable File

#! /bin/bash
SCRIPTDIR="$(dirname "$0")"
source "$SCRIPTDIR"/tests/helper.bash
if [ -z "$1" ]; then
output="$(findBin "$SCRIPTDIR"/server "$SCRIPTDIR"/../server)"
if [ $? -eq 0 ]; then
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
export FORGEHOOKENDPOINT="$output"
else
# Some warnings, print but use result from last line
echo "$output" | head -n -1
export FORGEHOOKENDPOINT="$(echo "$output" | tail -n 1)"
fi
else
echo "ERROR: Could not find webhook endpoint server starting script. Output:"
echo "$output"
exit 1
fi
else
export FORGEHOOKENDPOINT="$1"
fi
if [ -z "$2" ]; then
# First try symlink from script dir
# Second try compiled version from parent repo (endpoint implementation) in whck submodule
# Third try compiled version from whck folder in grandparent folder (eg. when called from
# forge/endpoints.php/spec/test_web.sh to find forge/whck/target/*/whck)
output="$(findBin \
"$SCRIPTDIR"/whck \
"$SCRIPTDIR"/../whck/target/release/whck \
"$SCRIPTDIR"/../whck/target/debug/whck \
"$SCRIPTDIR"/../../whck/target/release/whck \
"$SCRIPTDIR"/../../whck/target/debug/whck \
)"
if [ $? -eq 0 ]; then
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
export WHCK="$output"
else
# Some warnings, print but use result from last line
echo "$output" | head -n -1
export WHCK="$(echo "$output" | tail -n 1)"
fi
else
echo "ERROR: Could not find webhook check program (whck). Output:"
echo "$output"
exit 1
fi
else
export WHCK="$2"
fi
ORIGDIR="$(pwd)"
cd "$SCRIPTDIR"
export FORGEHOOK="$(pwd)/tests/mock-forgehook.sh"
export FORGEHOOKNOTIFY=/bin/true
bats tests/web/*.bats
cd "$ORIGDIR"