1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/bin/sh
#
# This test builds and runs the SelfTest tool that is shipped in the source
# package.
#
set -eu
SRCDIR="$AUTOPKGTEST_TMP"/source
BLDDIR="$AUTOPKGTEST_TMP"/build
mkdir -p "$SRCDIR"
cat >"$SRCDIR"/CMakeLists.txt <<-EOF
cmake_minimum_required(VERSION 3.10)
project(SelfTest CXX)
set(TEST_SRCDIR $(pwd)/tests/SelfTest)
file(GLOB_RECURSE TEST_SOURCES \${TEST_SRCDIR}/*.cpp)
add_executable(SelfTest \${TEST_SOURCES})
find_package(PkgConfig REQUIRED)
pkg_check_modules(CATCH2 REQUIRED catch2-with-main)
target_compile_options(SelfTest PUBLIC \${CATCH2_CFLAGS_OTHERS})
target_include_directories(SelfTest PUBLIC \${CATCH2_INCLUDE_DIRS})
target_include_directories(SelfTest PRIVATE \${TEST_SRCDIR})
target_link_libraries(SelfTest \${CATCH2_LIBRARIES})
EOF
cmake -S "$SRCDIR" -B "$BLDDIR"
make -C "$BLDDIR" -j "$(nproc)"
exec "$BLDDIR"/SelfTest
|