From 23fe60a06788352f6140a2570869d1352cf30c8b Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 2 Oct 2020 22:46:23 +0200 Subject: [PATCH] Run unit tests in a separate build --- .travis.yml | 8 +++++- CI/before_script.linux.sh | 51 +++++++++++++++++++++++++++------------ CI/build_googletest.sh | 12 ++++++--- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36b15d794c..8d98d0dd43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,12 @@ matrix: os: linux dist: focal if: branch != coverity_scan + - name: OpenMW (tests only) on Ubuntu Focal with GCC + os: linux + dist: focal + if: branch != coverity_scan + env: + - BUILD_TESTS_ONLY: 1 - name: OpenMW (openmw) on Ubuntu Focal with Clang's Static Analysis os: linux dist: focal @@ -73,7 +79,7 @@ script: - if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then ${ANALYZE} make -j3; fi - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then make package; fi - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then ../CI/check_package.osx.sh; fi - - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./openmw_test_suite; fi + - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TESTS_ONLY}" ]; then ./openmw_test_suite; fi - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then cd .. && ./CI/check_tabs.sh; fi - cd "${TRAVIS_BUILD_DIR}" - ccache -s diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index f4aaeecc9d..6df3dc32e0 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -2,22 +2,43 @@ free -m -env GENERATOR='Unix Makefiles' CONFIGURATION=Release CI/build_googletest.sh -GOOGLETEST_DIR="$(pwd)/googletest/build" +if [[ "${BUILD_TESTS_ONLY}" ]]; then + export GOOGLETEST_DIR="$(pwd)/googletest/build/install" + env GENERATOR='Unix Makefiles' CONFIGURATION=Release CI/build_googletest.sh +fi mkdir build cd build -${ANALYZE} cmake \ - -DCMAKE_C_COMPILER="${CC}" \ - -DCMAKE_CXX_COMPILER="${CXX}" \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DBUILD_UNITTESTS=TRUE \ - -DUSE_SYSTEM_TINYXML=TRUE \ - -DCMAKE_INSTALL_PREFIX="/usr" \ - -DBINDIR="/usr/games" \ - -DCMAKE_BUILD_TYPE="DEBUG" \ - -DGTEST_ROOT="${GOOGLETEST_DIR}" \ - -DGMOCK_ROOT="${GOOGLETEST_DIR}" \ - .. +if [[ "${BUILD_TESTS_ONLY}" ]]; then + ${ANALYZE} cmake \ + -D CMAKE_C_COMPILER="${CC}" \ + -D CMAKE_CXX_COMPILER="${CXX}" \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -D CMAKE_INSTALL_PREFIX=install \ + -D CMAKE_BUILD_TYPE=RelWithDebInfo \ + -D USE_SYSTEM_TINYXML=TRUE \ + -D BUILD_OPENMW=OFF \ + -D BUILD_BSATOOL=OFF \ + -D BUILD_ESMTOOL=OFF \ + -D BUILD_LAUNCHER=OFF \ + -D BUILD_MWINIIMPORTER=OFF \ + -D BUILD_ESSIMPORTER=OFF \ + -D BUILD_OPENCS=OFF \ + -D BUILD_WIZARD=OFF \ + -D BUILD_UNITTESTS=ON \ + -D GTEST_ROOT="${GOOGLETEST_DIR}" \ + -D GMOCK_ROOT="${GOOGLETEST_DIR}" \ + .. +else + ${ANALYZE} cmake \ + -D CMAKE_C_COMPILER="${CC}" \ + -D CMAKE_CXX_COMPILER="${CXX}" \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -D USE_SYSTEM_TINYXML=TRUE \ + -D CMAKE_INSTALL_PREFIX=install \ + -D CMAKE_BUILD_TYPE=Debug \ + .. +fi diff --git a/CI/build_googletest.sh b/CI/build_googletest.sh index 0ffda7f9bc..a9a50fee7a 100755 --- a/CI/build_googletest.sh +++ b/CI/build_googletest.sh @@ -1,13 +1,17 @@ -#!/bin/sh -e +#!/bin/sh -ex git clone -b release-1.10.0 https://github.com/google/googletest.git cd googletest mkdir build cd build cmake \ + -D CMAKE_C_COMPILER="${CC}" \ + -D CMAKE_CXX_COMPILER="${CXX}" \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ -D CMAKE_BUILD_TYPE="${CONFIGURATION}" \ - -D CMAKE_INSTALL_PREFIX=. \ + -D CMAKE_INSTALL_PREFIX="${GOOGLETEST_DIR}" \ -G "${GENERATOR}" \ .. -cmake --build . --config "${CONFIGURATION}" -cmake --build . --target install --config "${CONFIGURATION}" +cmake --build . --config "${CONFIGURATION}" -- -j $(nproc) +cmake --install . --config "${CONFIGURATION}"