#! /bin/bash

# Arguments:
# 1. Test path/file (relative to "tests" folder)
# 2. Optional server to run (relative to "tests" folder)

BUILD_FOLDER=@CMAKE_BINARY_DIR@

# start optional server provided in $2
if [[ $2 ]] ; then
    echo "SERVER: $2 & sleep 0.2"
    "$2" &
    sleep 0.2
fi

# execute test provided in $1 with backend provided in $2
echo "CLIENT: $1"
"$1"

EXIT_CODE=$?

# kill background server process
[[ $2 ]] && kill $!

exit $EXIT_CODE

