Skip to content

Commit 6faac1b

Browse files
authored
Merge pull request #65 from jlinenkohl/pr-u1-catch2-auto-init
tests: auto-init Catch2 submodule in unit harness
2 parents a6a044c + 2f69f4f commit 6faac1b

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

tests/run_unit_tests.sh

100644100755
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
FOLDER=build_unittests
2-
set -e
1+
#!/usr/bin/env bash
2+
set -euo pipefail
33

4-
mkdir -p $FOLDER
5-
pushd $FOLDER
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
6+
FOLDER="${SCRIPT_DIR}/build_unittests"
7+
8+
if [[ ! -f "${ROOT_DIR}/tests/Catch2/CMakeLists.txt" ]]; then
9+
echo "Catch2 checkout missing; initializing tests/Catch2 submodule..."
10+
git -C "${ROOT_DIR}" submodule update --init --recursive tests/Catch2
11+
fi
12+
13+
if [[ ! -f "${ROOT_DIR}/tests/Catch2/CMakeLists.txt" ]]; then
14+
echo "Failed to initialize tests/Catch2/CMakeLists.txt."
15+
exit 1
16+
fi
17+
18+
mkdir -p "${FOLDER}"
19+
pushd "${FOLDER}" >/dev/null
620
cmake ../unit -DCMAKE_BUILD_TYPE=Debug
7-
make -j4
8-
ctest --verbose . $@
9-
popd
21+
cmake --build . -j4
22+
ctest --verbose "$@"
23+
popd >/dev/null

0 commit comments

Comments
 (0)