diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 442cd814..13b00d01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: - name: macos-apple-clang os: macos-latest + compiler-cppstd: "gnu17" - name: windows-msvc-19 os: windows-2019 @@ -69,10 +70,13 @@ jobs: run: | conan profile detect --force if [ "${{ matrix.compiler-name-conan }}" != "" ]; then - sed -i 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default + sed -i.bak -e 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default fi if [ "${{ matrix.compiler-version }}" != "" ]; then - sed -i 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default + sed -i.bak -e 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default + fi + if [ "${{ matrix.compiler-cppstd }}" != "" ]; then + sed -i.bak -e 's/compiler.cppstd=gnu[0-9]\+/compiler.cppstd=${{ matrix.compiler-cppstd }}/g' ~/.conan2/profiles/default fi shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 77313471..5faa0b8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ project( LANGUAGES CXX) include(GNUInstallDirs) -include(CTest) option(SI_INSTALL_LIBRARY "Enable installing of SI library into default locations" @@ -44,7 +43,9 @@ target_include_directories( target_compile_features(SI INTERFACE cxx_std_17) -if(BUILD_TESTING AND SI_BUILD_TESTING) +if(SI_BUILD_TESTING) + enable_testing() + include(Catch) add_subdirectory(test) endif() diff --git a/test/compilation-tests.sh b/test/compilation-tests.sh index 41cf08f1..6c036394 100755 --- a/test/compilation-tests.sh +++ b/test/compilation-tests.sh @@ -10,15 +10,15 @@ buildSingleTarget() if [ "${2}" == "DEFAULTBUILD" ]; then cmake ${ROOT_DIR}/test/src/compilation_tests/ -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null assertEquals "Configuration successful" 0 $? - + else cmake ${ROOT_DIR}/test/src/compilation_tests/ -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-DSI_DISABLE_IMPLICIT_RATIO_CONVERSION" -G Ninja > /dev/null assertEquals "Configuration successful" 0 $? fi - + cmake --build ${BUILD_DIR} --config Release --target $1 > /dev/null RESULT=$? - + if [ "${3}" == "PASS" ]; then assertEquals "Building successful" 0 $RESULT else @@ -27,14 +27,14 @@ buildSingleTarget() } oneTimeSetUp(){ - + BUILD_DIR=$(mktemp -d) conan install . --output-folder=${BUILD_DIR} --build=missing --settings=build_type=Release 2>&1> /dev/null - + # install SI - cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null + cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja > /dev/null cmake --build ${BUILD_DIR} --config Release --target install > /dev/null - + if [ -d ${BUILD_DIR} ]; then rm -rf ${BUILD_DIR} fi @@ -52,7 +52,7 @@ tearDown(){ } testSISelfSuccessfulCompilationWhenDefaultInvocation() { - + cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${BUILD_DIR} -G Ninja > /dev/null assertEquals "Configuration successful" 0 $? cmake --build ${BUILD_DIR} --config Release > /dev/null @@ -60,7 +60,7 @@ testSISelfSuccessfulCompilationWhenDefaultInvocation() { } testSISelfFailedCompilationWhenImplicitConversionDisabled() { - + cmake ${ROOT_DIR} -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${BUILD_DIR} -DCMAKE_CXX_FLAGS="-DSI_DISABLE_IMPLICIT_RATIO_CONVERSION" -G Ninja > /dev/null assertEquals "Configuration successful" 0 $? cmake --build ${BUILD_DIR} --config Release @@ -347,4 +347,4 @@ testCompilationSucceedsWhenNumberParserDoesNotOverflow() # Load shUnit2. -. shunit2 \ No newline at end of file +. shunit2 diff --git a/test/installation-tests.sh b/test/installation-tests.sh index 2cc4d551..5ed4deeb 100755 --- a/test/installation-tests.sh +++ b/test/installation-tests.sh @@ -17,11 +17,11 @@ tearDown() { if [ -d ${SI_BUILD_DIR} ]; then rm -rf ${SI_BUILD_DIR} fi - + if [ -d ${INSTALL_PATH} ]; then rm -rf ${INSTALL_PATH} fi - + if [ -d ${BUILD_DIR} ]; then rm -rf ${BUILD_DIR} fi @@ -29,30 +29,30 @@ tearDown() { testPureCmakeInstallation() { # install SI - cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release + cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release cmake --build ${SI_BUILD_DIR} --config Release --target install assertEquals "Installation build successful" 0 $? cmake ${ROOT_DIR}/test/installation-tests -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} cmake --build ${BUILD_DIR} assertEquals "build against installation successful" 0 $? - + } testPureCmakeInstallationWithInstallOptionTurnedOff() { # install SI - cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DBUILD_TESTING=off -DSI_INSTALL_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Release + cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} -DSI_BUILD_TESTING=OFF -DSI_INSTALL_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Release cmake --build ${SI_BUILD_DIR} --config Release --target install assertNotEquals "Installation build successful" 0 $? - + DIRECTORY_CONTENTS=$(ls -A ${INSTALL_PATH}) EMPTY="" assertEquals "Installation directory is empty" "${EMPTY}" "${DIRECTORY_CONTENTS}" - + } testCpackInstallation() { # install SI - cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCPACK_PACKAGE_FILE_NAME=install-SI -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Release + cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DCPACK_PACKAGE_FILE_NAME=install-SI -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release cmake --build ${SI_BUILD_DIR} --config Release --target package assertEquals "Installation build successful" 0 $? if [ "${OS_NAME}" = "Linux" ] || [ "${OS_NAME}" = "Darwin" ]; then @@ -63,13 +63,13 @@ testCpackInstallation() { # echo "done" return fi - + assertEquals "Installation script successful" 0 $? - + cmake ${ROOT_DIR}/test/installation-tests -B${BUILD_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} cmake --build ${BUILD_DIR} assertEquals "build against installation successful" 0 $? - + } @@ -78,7 +78,7 @@ testUsageAsSubdirectory() { cmake ${ROOT_DIR}/test/installation-test-subdirectory -B${BUILD_DIR} -DCMAKE_BUILD_TYPE=Release cmake --build ${BUILD_DIR} assertEquals "build against installation successful" 0 $? - + } # Load shUnit2. diff --git a/test/version-consistency.sh b/test/version-consistency.sh index 9e700013..1d6dce41 100755 --- a/test/version-consistency.sh +++ b/test/version-consistency.sh @@ -24,7 +24,7 @@ testVersionNumberConsistency() { CHANGELOG_VERSION=$(sed -n -E '/## [0-9]+\.[0-9]+\.[0-9]+/p' ${ROOT_DIR}/CHANGELOG.md | head -1 | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+') ORIG_DIR=$(pwd) - cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DBUILD_TESTING=off -DCMAKE_BUILD_TYPE=Debug >/dev/null + cmake ${ROOT_DIR} -B${SI_BUILD_DIR} -DSI_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug >/dev/null cd ${SI_BUILD_DIR} CMAKE_VERSION=$(cmake --system-information | grep -E "VERSION:STATIC" | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+') cd ${ORIG_DIR}