Split openmw_test_suite into openmw and components tests

To avoid duplicated compilation for openmw translation units. Link openmw-lib to
openmw-tests instead.
pull/3236/head
elsid 7 months ago
parent 9b0362fba8
commit 7d1cd11ba9
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -1,11 +1,8 @@
name: CMake name: CMake
on: on:
push: - push
branches: - pull_request
- 'master'
pull_request:
branches: [ master ]
env: env:
BUILD_TYPE: RelWithDebInfo BUILD_TYPE: RelWithDebInfo
@ -30,13 +27,27 @@ jobs:
max-size: 1000M max-size: 1000M
- name: Configure - name: Configure
run: cmake . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOPENMW_USE_SYSTEM_RECASTNAVIGATION=1 -DUSE_SYSTEM_TINYXML=1 -DBUILD_UNITTESTS=1 -DCMAKE_INSTALL_PREFIX=install run: >
cmake .
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D OPENMW_USE_SYSTEM_RECASTNAVIGATION=ON
-D USE_SYSTEM_TINYXML=ON
-D BUILD_COMPONENTS_TESTS=ON
-D BUILD_OPENMW_TESTS=ON
-D BUILD_OPENCS_TESTS=ON
-D CMAKE_INSTALL_PREFIX=install
- name: Build - name: Build
run: make -j3 run: cmake --build . -- -j$(nproc)
- name: Test - name: Run components tests
run: ./openmw_test_suite run: ./components-tests
- name: Run OpenMW tests
run: ./openmw-tests
- name: Run OpenMW-CS tests
run: ./openmw-cs-tests
# - name: Install # - name: Install
# shell: bash # shell: bash

@ -69,15 +69,16 @@ Ubuntu_GCC_preprocess:
- df -h - df -h
- du -sh . - du -sh .
- cmake --install . - cmake --install .
- if [[ "${BUILD_TESTS_ONLY}" ]]; then ./openmw_test_suite --gtest_output="xml:openmw_tests.xml"; fi - if [[ "${BUILD_TESTS_ONLY}" ]]; then ./components-tests --gtest_output="xml:components-tests.xml"; fi
- if [[ "${BUILD_TESTS_ONLY}" ]]; then ./openmw-cs-tests --gtest_output="xml:openmw_cs_tests.xml"; fi - if [[ "${BUILD_TESTS_ONLY}" ]]; then ./openmw-tests --gtest_output="xml:openmw-tests.xml"; fi
- if [[ "${BUILD_TESTS_ONLY}" ]]; then ./openmw-cs-tests --gtest_output="xml:openmw-cs-tests.xml"; fi
- if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_detournavigator_navmeshtilescache_benchmark; fi - if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_detournavigator_navmeshtilescache_benchmark; fi
- if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_esm_refid_benchmark; fi - if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_esm_refid_benchmark; fi
- if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_settings_access_benchmark; fi - if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_settings_access_benchmark; fi
- ccache -s - ccache -s
- df -h - df -h
- if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then gcovr --xml-pretty --exclude-unreachable-branches --print-summary --root "${CI_PROJECT_DIR}" -j $(nproc) -o ../coverage.xml; fi - if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then gcovr --xml-pretty --exclude-unreachable-branches --print-summary --root "${CI_PROJECT_DIR}" -j $(nproc) -o ../coverage.xml; fi
- ls | grep -v -e '^extern$' -e '^install$' -e '^openmw_tests.xml$' -e '^openmw_cs_tests.xml$' | xargs -I '{}' rm -rf './{}' - ls | grep -v -e '^extern$' -e '^install$' -e '^components-tests.xml$' -e '^openmw-tests.xml$' -e '^openmw-cs-tests.xml$' | xargs -I '{}' rm -rf './{}'
- cd .. - cd ..
- df -h - df -h
- du -sh build/ - du -sh build/
@ -422,7 +423,7 @@ Ubuntu_Clang_Tidy_other:
needs: needs:
- Ubuntu_Clang_Tidy_components - Ubuntu_Clang_Tidy_components
variables: variables:
BUILD_TARGETS: bsatool esmtool openmw-launcher openmw-iniimporter openmw-essimporter openmw-wizard niftest openmw_test_suite openmw-navmeshtool openmw-bulletobjecttool BUILD_TARGETS: bsatool esmtool openmw-launcher openmw-iniimporter openmw-essimporter openmw-wizard niftest components-tests openmw-tests openmw-cs-tests openmw-navmeshtool openmw-bulletobjecttool
timeout: 3h timeout: 3h
.Ubuntu_Clang_tests: .Ubuntu_Clang_tests:
@ -645,7 +646,7 @@ macOS14_Xcode15_arm64:
variables: variables:
config: "RelWithDebInfo" config: "RelWithDebInfo"
# Gitlab can't successfully execute following binaries due to unknown reason # Gitlab can't successfully execute following binaries due to unknown reason
# executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" # executables: "components-tests.exe,openmw-tests.exe,openmw-cs-tests.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe"
.Windows_MSBuild_Base: .Windows_MSBuild_Base:
tags: tags:
@ -747,7 +748,7 @@ Windows_MSBuild_RelWithDebInfo:
variables: variables:
config: "RelWithDebInfo" config: "RelWithDebInfo"
# Gitlab can't successfully execute following binaries due to unknown reason # Gitlab can't successfully execute following binaries due to unknown reason
# executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" # executables: "components-tests.exe,openmw-tests.exe,openmw-cs-tests.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe"
# temporarily enabled while we're linking these on the downloads page # temporarily enabled while we're linking these on the downloads page
rules: rules:
# run this for both pushes and schedules so 'latest successful pipeline for branch' always includes it # run this for both pushes and schedules so 'latest successful pipeline for branch' always includes it

@ -7,14 +7,6 @@ free -m
# Silence a git warning # Silence a git warning
git config --global advice.detachedHead false git config --global advice.detachedHead false
BUILD_UNITTESTS=OFF
BUILD_BENCHMARKS=OFF
if [[ "${BUILD_TESTS_ONLY}" ]]; then
BUILD_UNITTESTS=ON
BUILD_BENCHMARKS=ON
fi
# setup our basic cmake build options # setup our basic cmake build options
declare -a CMAKE_CONF_OPTS=( declare -a CMAKE_CONF_OPTS=(
-DCMAKE_C_COMPILER="${CC:-/usr/bin/cc}" -DCMAKE_C_COMPILER="${CC:-/usr/bin/cc}"
@ -47,13 +39,13 @@ fi
if [[ $CI_CLANG_TIDY ]]; then if [[ $CI_CLANG_TIDY ]]; then
CMAKE_CONF_OPTS+=( CMAKE_CONF_OPTS+=(
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*" -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*"
-DBUILD_UNITTESTS=ON -DBUILD_COMPONENTS_TESTS=ON
-DBUILD_OPENMW_TESTS=ON
-DBUILD_OPENCS_TESTS=ON -DBUILD_OPENCS_TESTS=ON
-DBUILD_BENCHMARKS=ON -DBUILD_BENCHMARKS=ON
) )
fi fi
if [[ "${CMAKE_BUILD_TYPE}" ]]; then if [[ "${CMAKE_BUILD_TYPE}" ]]; then
CMAKE_CONF_OPTS+=( CMAKE_CONF_OPTS+=(
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
@ -103,9 +95,10 @@ if [[ "${BUILD_TESTS_ONLY}" ]]; then
-DBUILD_NAVMESHTOOL=OFF \ -DBUILD_NAVMESHTOOL=OFF \
-DBUILD_BULLETOBJECTTOOL=OFF \ -DBUILD_BULLETOBJECTTOOL=OFF \
-DBUILD_NIFTEST=OFF \ -DBUILD_NIFTEST=OFF \
-DBUILD_UNITTESTS=${BUILD_UNITTESTS} \ -DBUILD_COMPONENTS_TESTS=ON \
-DBUILD_OPENCS_TESTS=${BUILD_UNITTESTS} \ -DBUILD_OPENMW_TESTS=ON \
-DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \ -DBUILD_OPENCS_TESTS=ON \
-DBUILD_BENCHMARKS=ON \
.. ..
elif [[ "${BUILD_OPENMW_ONLY}" ]]; then elif [[ "${BUILD_OPENMW_ONLY}" ]]; then
${ANALYZE} cmake \ ${ANALYZE} cmake \

@ -1169,8 +1169,9 @@ if [ "${BUILD_BENCHMARKS}" ]; then
fi fi
if [ -n "${TEST_FRAMEWORK}" ]; then if [ -n "${TEST_FRAMEWORK}" ]; then
add_cmake_opts -DBUILD_UNITTESTS=ON add_cmake_opts -DBUILD_COMPONENTS_TESTS=ON
add_cmake_opts -DBUILD_OPENCS_TESTS=ON add_cmake_opts -DBUILD_OPENCS_TESTS=ON
add_cmake_opts -DBUILD_OPENMW_TESTS=ON
fi fi
if [ -n "$ACTIVATE_MSVC" ]; then if [ -n "$ACTIVATE_MSVC" ]; then

@ -8,28 +8,26 @@ apps/openmw/mwsound/sound_buffer.cpp
apps/openmw/mwsound/sound_buffer.hpp apps/openmw/mwsound/sound_buffer.hpp
apps/openmw/mwsound/sound_decoder.hpp apps/openmw/mwsound/sound_decoder.hpp
apps/openmw/mwsound/sound_output.hpp apps/openmw/mwsound/sound_output.hpp
apps/openmw_test_suite/esm/test_fixed_string.cpp apps/components_tests/esm/test_fixed_string.cpp
apps/openmw_test_suite/files/conversion_tests.cpp apps/components_tests/files/conversion_tests.cpp
apps/openmw_test_suite/lua/test_async.cpp apps/components_tests/lua/test_async.cpp
apps/openmw_test_suite/lua/test_configuration.cpp apps/components_tests/lua/test_configuration.cpp
apps/openmw_test_suite/lua/test_l10n.cpp apps/components_tests/lua/test_l10n.cpp
apps/openmw_test_suite/lua/test_lua.cpp apps/components_tests/lua/test_lua.cpp
apps/openmw_test_suite/lua/test_scriptscontainer.cpp apps/components_tests/lua/test_scriptscontainer.cpp
apps/openmw_test_suite/lua/test_serialization.cpp apps/components_tests/lua/test_serialization.cpp
apps/openmw_test_suite/lua/test_storage.cpp apps/components_tests/lua/test_storage.cpp
apps/openmw_test_suite/lua/test_ui_content.cpp apps/components_tests/lua/test_ui_content.cpp
apps/openmw_test_suite/lua/test_utilpackage.cpp apps/components_tests/lua/test_utilpackage.cpp
apps/openmw_test_suite/lua/test_inputactions.cpp apps/components_tests/lua/test_inputactions.cpp
apps/openmw_test_suite/lua/test_yaml.cpp apps/components_tests/lua/test_yaml.cpp
apps/openmw_test_suite/misc/test_endianness.cpp apps/components_tests/misc/test_endianness.cpp
apps/openmw_test_suite/misc/test_resourcehelpers.cpp apps/components_tests/misc/test_resourcehelpers.cpp
apps/openmw_test_suite/misc/test_stringops.cpp apps/components_tests/misc/test_stringops.cpp
apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp apps/openmw_tests/mwdialogue/test_keywordsearch.cpp
apps/openmw_test_suite/mwscript/test_scripts.cpp apps/openmw_tests/mwscript/test_scripts.cpp
apps/openmw_test_suite/mwscript/test_utils.hpp apps/openmw_tests/mwscript/test_utils.hpp
apps/openmw_test_suite/mwworld/test_store.cpp apps/openmw_tests/mwworld/test_store.cpp
apps/openmw_test_suite/openmw_test_suite.cpp
apps/openmw_test_suite/testing_util.hpp
components/bsa/bsa_file.cpp components/bsa/bsa_file.cpp
components/bsa/bsa_file.hpp components/bsa/bsa_file.hpp
components/crashcatcher/windows_crashcatcher.cpp components/crashcatcher/windows_crashcatcher.cpp

@ -31,7 +31,8 @@ cmake \
-D BUILD_OPENCS=ON \ -D BUILD_OPENCS=ON \
-D BUILD_OPENCS_TESTS=ON \ -D BUILD_OPENCS_TESTS=ON \
-D BUILD_OPENMW=ON \ -D BUILD_OPENMW=ON \
-D BUILD_UNITTESTS=ON \ -D BUILD_OPENMW_TESTS=ON \
-D BUILD_COMPONENTS_TESTS=ON \
-D BUILD_WIZARD=ON \ -D BUILD_WIZARD=ON \
"${SRC}" "${SRC}"
cmake --build . --parallel cmake --build . --parallel

@ -39,11 +39,12 @@ option(BUILD_ESMTOOL "Build ESM inspector" ON)
option(BUILD_NIFTEST "Build nif file tester" ON) option(BUILD_NIFTEST "Build nif file tester" ON)
option(BUILD_DOCS "Build documentation." OFF ) option(BUILD_DOCS "Build documentation." OFF )
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF) option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest" OFF) option(BUILD_COMPONENTS_TESTS "Build components library tests" OFF)
option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF) option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF)
option(BUILD_NAVMESHTOOL "Build navmesh tool" ON) option(BUILD_NAVMESHTOOL "Build navmesh tool" ON)
option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON) option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON)
option(BUILD_OPENCS_TESTS "Build OpenMW Construction Set tests" OFF) option(BUILD_OPENCS_TESTS "Build OpenMW Construction Set tests" OFF)
option(BUILD_OPENMW_TESTS "Build OpenMW tests" OFF)
option(PRECOMPILE_HEADERS_WITH_MSVC "Precompile most common used headers with MSVC (alternative to ccache)" ON) option(PRECOMPILE_HEADERS_WITH_MSVC "Precompile most common used headers with MSVC (alternative to ccache)" ON)
set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up. set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up.
@ -305,7 +306,7 @@ if (OPENMW_USE_SYSTEM_YAML_CPP)
find_package(yaml-cpp REQUIRED) find_package(yaml-cpp REQUIRED)
endif() endif()
if ((BUILD_UNITTESTS OR BUILD_OPENCS_TESTS) AND OPENMW_USE_SYSTEM_GOOGLETEST) if ((BUILD_COMPONENTS_TESTS OR BUILD_OPENCS_TESTS OR BUILD_OPENMW_TESTS) AND OPENMW_USE_SYSTEM_GOOGLETEST)
find_package(GTest 1.10 REQUIRED) find_package(GTest 1.10 REQUIRED)
find_package(GMock 1.10 REQUIRED) find_package(GMock 1.10 REQUIRED)
endif() endif()
@ -642,7 +643,7 @@ endif()
add_subdirectory (components) add_subdirectory (components)
# Apps and tools # Apps and tools
if (BUILD_OPENMW) if (BUILD_OPENMW OR BUILD_OPENMW_TESTS)
add_subdirectory( apps/openmw ) add_subdirectory( apps/openmw )
endif() endif()
@ -676,11 +677,10 @@ endif()
if (BUILD_NIFTEST) if (BUILD_NIFTEST)
add_subdirectory(apps/niftest) add_subdirectory(apps/niftest)
endif(BUILD_NIFTEST) endif()
# UnitTests if (BUILD_COMPONENTS_TESTS)
if (BUILD_UNITTESTS) add_subdirectory(apps/components_tests)
add_subdirectory( apps/openmw_test_suite )
endif() endif()
if (BUILD_BENCHMARKS) if (BUILD_BENCHMARKS)
@ -692,13 +692,17 @@ if (BUILD_NAVMESHTOOL)
endif() endif()
if (BUILD_BULLETOBJECTTOOL) if (BUILD_BULLETOBJECTTOOL)
add_subdirectory( apps/bulletobjecttool ) add_subdirectory(apps/bulletobjecttool)
endif() endif()
if (BUILD_OPENCS_TESTS) if (BUILD_OPENCS_TESTS)
add_subdirectory(apps/opencs_tests) add_subdirectory(apps/opencs_tests)
endif() endif()
if (BUILD_OPENMW_TESTS)
add_subdirectory(apps/openmw_tests)
endif()
if (WIN32) if (WIN32)
if (MSVC) if (MSVC)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
@ -780,8 +784,8 @@ if (WIN32)
target_compile_options(openmw-wizard PRIVATE ${WARNINGS}) target_compile_options(openmw-wizard PRIVATE ${WARNINGS})
endif() endif()
if (BUILD_UNITTESTS) if (BUILD_COMPONENTS_TESTS)
target_compile_options(openmw_test_suite PRIVATE ${WARNINGS}) target_compile_options(components-tests PRIVATE ${WARNINGS})
endif() endif()
if (BUILD_BENCHMARKS) if (BUILD_BENCHMARKS)
@ -795,6 +799,14 @@ if (WIN32)
if (BUILD_BULLETOBJECTTOOL) if (BUILD_BULLETOBJECTTOOL)
target_compile_options(openmw-bulletobjecttool PRIVATE ${WARNINGS} ${MT_BUILD}) target_compile_options(openmw-bulletobjecttool PRIVATE ${WARNINGS} ${MT_BUILD})
endif() endif()
if (BUILD_OPENCS_TESTS)
target_compile_options(openmw-cs-tests PRIVATE ${WARNINGS})
endif()
if (BUILD_OPENMW_TESTS)
target_compile_options(openmw-tests PRIVATE ${WARNINGS})
endif()
endif(MSVC) endif(MSVC)
# TODO: At some point release builds should not use the console but rather write to a log file # TODO: At some point release builds should not use the console but rather write to a log file

@ -2,19 +2,7 @@ include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS}) include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS})
file(GLOB UNITTEST_SRC_FILES file(GLOB UNITTEST_SRC_FILES
testing_util.hpp main.cpp
../openmw/mwworld/store.cpp
../openmw/mwworld/esmstore.cpp
../openmw/mwworld/timestamp.cpp
mwworld/test_store.cpp
mwworld/testduration.cpp
mwworld/testtimestamp.cpp
mwdialogue/test_keywordsearch.cpp
mwscript/test_scripts.cpp
esm/test_fixed_string.cpp esm/test_fixed_string.cpp
esm/variant.cpp esm/variant.cpp
@ -66,9 +54,6 @@ file(GLOB UNITTEST_SRC_FILES
shader/parselinks.cpp shader/parselinks.cpp
shader/shadermanager.cpp shader/shadermanager.cpp
../openmw/options.cpp
openmw/options.cpp
sqlite3/db.cpp sqlite3/db.cpp
sqlite3/request.cpp sqlite3/request.cpp
sqlite3/statement.cpp sqlite3/statement.cpp
@ -104,19 +89,24 @@ file(GLOB UNITTEST_SRC_FILES
sceneutil/osgacontroller.cpp sceneutil/osgacontroller.cpp
) )
source_group(apps\\openmw_test_suite FILES openmw_test_suite.cpp ${UNITTEST_SRC_FILES}) source_group(apps\\components-tests FILES ${UNITTEST_SRC_FILES})
openmw_add_executable(components-tests ${UNITTEST_SRC_FILES})
openmw_add_executable(openmw_test_suite openmw_test_suite.cpp ${UNITTEST_SRC_FILES}) target_link_libraries(components-tests
GTest::GTest
GMock::GMock
components
)
target_link_libraries(openmw_test_suite GTest::GTest GMock::GMock components)
# Fix for not visible pthreads functions for linker with glibc 2.15 # Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(openmw_test_suite ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(components-tests ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_test_suite PRIVATE --coverage) target_compile_options(components-tests PRIVATE --coverage)
target_link_libraries(openmw_test_suite gcov) target_link_libraries(components-tests gcov)
endif() endif()
file(DOWNLOAD file(DOWNLOAD
@ -125,12 +115,12 @@ file(DOWNLOAD
EXPECTED_HASH SHA512=6e38642bcf013c5f496a9cb0bf3ec7c9553b6e86b836e7844824c5a05f556c9391167214469b6318401684b702d7569896bf743c85aee4198612b3315ba778d6 EXPECTED_HASH SHA512=6e38642bcf013c5f496a9cb0bf3ec7c9553b6e86b836e7844824c5a05f556c9391167214469b6318401684b702d7569896bf743c85aee4198612b3315ba778d6
) )
target_compile_definitions(openmw_test_suite target_compile_definitions(components-tests
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data" PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}") OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}")
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC) if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw_test_suite PRIVATE target_precompile_headers(components-tests PRIVATE
<boost/program_options/options_description.hpp> <boost/program_options/options_description.hpp>
<gtest/gtest.h> <gtest/gtest.h>

@ -1,6 +1,7 @@
#include "components/esm/refid.hpp" #include <components/esm/refid.hpp>
#include "components/esm3/esmreader.hpp" #include <components/esm3/esmreader.hpp>
#include "components/esm3/esmwriter.hpp" #include <components/esm3/esmwriter.hpp>
#include <components/testing/util.hpp>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -9,8 +10,6 @@
#include <map> #include <map>
#include <string> #include <string>
#include "../testing_util.hpp"
MATCHER(IsPrint, "") MATCHER(IsPrint, "")
{ {
return std::isprint(arg) != 0; return std::isprint(arg) != 0;

@ -1,5 +1,7 @@
#include <components/files/constrainedfilestream.hpp> #include <components/files/constrainedfilestream.hpp>
#include <components/files/conversion.hpp>
#include <components/files/hash.hpp> #include <components/files/hash.hpp>
#include <components/testing/util.hpp>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -10,10 +12,6 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <components/files/conversion.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {
using namespace testing; using namespace testing;

@ -1,12 +1,11 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/fx/technique.hpp> #include <components/fx/technique.hpp>
#include <components/resource/imagemanager.hpp> #include <components/resource/imagemanager.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,10 +1,9 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/lua/asyncpackage.hpp> #include <components/lua/asyncpackage.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,4 +1,4 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <fstream> #include <fstream>
@ -9,8 +9,7 @@
#include <components/esm3/readerscache.hpp> #include <components/esm3/readerscache.hpp>
#include <components/lua/configuration.hpp> #include <components/lua/configuration.hpp>
#include <components/lua/serialization.hpp> #include <components/lua/serialization.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,10 +1,9 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/lua/inputactions.hpp> #include <components/lua/inputactions.hpp>
#include <components/lua/scriptscontainer.hpp> #include <components/lua/scriptscontainer.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,13 +1,11 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/files/fixedpath.hpp> #include <components/files/fixedpath.hpp>
#include <components/l10n/manager.hpp> #include <components/l10n/manager.hpp>
#include <components/lua/l10n.hpp> #include <components/lua/l10n.hpp>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,9 +1,8 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -1,4 +1,4 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/esm/luascripts.hpp> #include <components/esm/luascripts.hpp>
@ -7,7 +7,7 @@
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/scriptscontainer.hpp> #include <components/lua/scriptscontainer.hpp>
#include "../testing_util.hpp" #include <components/testing/util.hpp>
namespace namespace
{ {

@ -1,4 +1,4 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <osg/Matrixf> #include <osg/Matrixf>
@ -13,7 +13,7 @@
#include <components/misc/color.hpp> #include <components/misc/color.hpp>
#include <components/misc/endianness.hpp> #include <components/misc/endianness.hpp>
#include "../testing_util.hpp" #include <components/testing/util.hpp>
namespace namespace
{ {

@ -1,10 +1,9 @@
#include "gmock/gmock.h" #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <components/lua/luastate.hpp> #include <components/lua/luastate.hpp>
#include <components/lua/utilpackage.hpp> #include <components/lua/utilpackage.hpp>
#include <components/testing/util.hpp>
#include "../testing_util.hpp"
namespace namespace
{ {

@ -6,15 +6,8 @@
#include <filesystem> #include <filesystem>
#ifdef WIN32
// we cannot use GTEST_API_ before main if we're building standalone exe application,
// and we're linking GoogleTest / GoogleMock as DLLs and not linking gtest_main / gmock_main
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
#else
GTEST_API_ int main(int argc, char** argv)
{
#endif
const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files" const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files"
/ Misc::StringUtils::stringToU8String("settings-default.cfg"); / Misc::StringUtils::stringToU8String("settings-default.cfg");

@ -1,5 +1,6 @@
#include "../testing_util.hpp" #include <components/misc/resourcehelpers.hpp>
#include "components/misc/resourcehelpers.hpp" #include <components/testing/util.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace namespace

@ -1,11 +1,10 @@
#include <components/settings/parser.hpp> #include <components/settings/parser.hpp>
#include <components/testing/util.hpp>
#include <fstream> #include <fstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "../testing_util.hpp"
namespace namespace
{ {
using namespace testing; using namespace testing;

@ -1,12 +1,11 @@
#include <components/settings/shadermanager.hpp> #include <components/settings/shadermanager.hpp>
#include <components/testing/util.hpp>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "../testing_util.hpp"
namespace namespace
{ {
using namespace testing; using namespace testing;

@ -1,12 +1,11 @@
#include <components/files/conversion.hpp> #include <components/files/conversion.hpp>
#include <components/shader/shadermanager.hpp> #include <components/shader/shadermanager.hpp>
#include <components/testing/util.hpp>
#include <fstream> #include <fstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "../testing_util.hpp"
namespace namespace
{ {
using namespace testing; using namespace testing;

@ -26,7 +26,7 @@ namespace
{ {
std::ifstream file; std::ifstream file;
file.exceptions(std::ios::failbit | std::ios::badbit); file.exceptions(std::ios::failbit | std::ios::badbit);
file.open(std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "apps" / "openmw_test_suite" / "toutf8" / "data" file.open(std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "apps" / "components_tests" / "toutf8" / "data"
/ Misc::StringUtils::stringToU8String(fileName)); / Misc::StringUtils::stringToU8String(fileName));
std::stringstream buffer; std::stringstream buffer;
buffer << file.rdbuf(); buffer << file.rdbuf();

@ -132,7 +132,15 @@ if (NOT ANDROID)
if(NOT WIN32) if(NOT WIN32)
set_target_properties(openmw-lib PROPERTIES OUTPUT_NAME openmw) set_target_properties(openmw-lib PROPERTIES OUTPUT_NAME openmw)
endif() endif()
endif ()
if(BUILD_OPENMW)
if (ANDROID)
add_library(openmw-lib SHARED
${OPENMW_FILES}
${OPENMW_SOURCES}
)
else()
openmw_add_executable(openmw openmw_add_executable(openmw
${APPLE_BUNDLE_RESOURCES} ${APPLE_BUNDLE_RESOURCES}
${OPENMW_RESOURCES} ${OPENMW_RESOURCES}
@ -140,12 +148,8 @@ if (NOT ANDROID)
) )
target_link_libraries(openmw openmw-lib) target_link_libraries(openmw openmw-lib)
else () endif()
add_library(openmw-lib SHARED endif()
${OPENMW_FILES}
${OPENMW_SOURCES}
)
endif ()
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING # Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
# when we change the backend. # when we change the backend.
@ -221,7 +225,7 @@ if (UNIX AND NOT APPLE)
target_link_libraries(openmw-lib ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(openmw-lib ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if(APPLE) if(APPLE AND BUILD_OPENMW)
set(BUNDLE_RESOURCES_DIR "${APP_BUNDLE_DIR}/Contents/Resources") set(BUNDLE_RESOURCES_DIR "${APP_BUNDLE_DIR}/Contents/Resources")
set(OPENMW_RESOURCES_ROOT ${BUNDLE_RESOURCES_DIR}) set(OPENMW_RESOURCES_ROOT ${BUNDLE_RESOURCES_DIR})
@ -252,12 +256,12 @@ endif(APPLE)
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-lib PRIVATE --coverage) target_compile_options(openmw-lib PRIVATE --coverage)
target_link_libraries(openmw-lib gcov) target_link_libraries(openmw-lib gcov)
if (NOT ANDROID) if (NOT ANDROID AND BUILD_OPENMW)
target_compile_options(openmw PRIVATE --coverage) target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov) target_link_libraries(openmw gcov)
endif() endif()
endif() endif()
if (WIN32) if (WIN32 AND BUILD_OPENMW)
INSTALL(TARGETS openmw RUNTIME DESTINATION ".") INSTALL(TARGETS openmw RUNTIME DESTINATION ".")
endif (WIN32) endif (WIN32)

@ -0,0 +1,58 @@
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS})
file(GLOB UNITTEST_SRC_FILES
main.cpp
options.cpp
mwworld/test_store.cpp
mwworld/testduration.cpp
mwworld/testtimestamp.cpp
mwdialogue/test_keywordsearch.cpp
mwscript/test_scripts.cpp
)
source_group(apps\\openmw-tests FILES ${UNITTEST_SRC_FILES})
openmw_add_executable(openmw-tests ${UNITTEST_SRC_FILES})
target_link_libraries(openmw-tests
GTest::GTest
GMock::GMock
openmw-lib
)
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(openmw-tests ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-tests PRIVATE --coverage)
target_link_libraries(openmw-tests gcov)
endif()
target_compile_definitions(openmw-tests
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}")
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw-tests PRIVATE
<boost/program_options/options_description.hpp>
<gtest/gtest.h>
<sol/sol.hpp>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<string>
<vector>
)
endif()

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
int main(int argc, char* argv[])
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -22,21 +22,10 @@
#include <components/files/conversion.hpp> #include <components/files/conversion.hpp>
#include <components/loadinglistener/loadinglistener.hpp> #include <components/loadinglistener/loadinglistener.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include <components/testing/util.hpp>
#include "apps/openmw/mwmechanics/spelllist.hpp"
#include "apps/openmw/mwworld/esmstore.hpp" #include "apps/openmw/mwworld/esmstore.hpp"
#include "../testing_util.hpp"
namespace MWMechanics
{
SpellList::SpellList(const ESM::RefId& id, int type)
: mId(id)
, mType(type)
{
}
}
static Loading::Listener dummyListener; static Loading::Listener dummyListener;
/// Base class for tests of ESMStore that rely on external content files to produce the test results /// Base class for tests of ESMStore that rely on external content files to produce the test results

@ -512,6 +512,10 @@ else ()
) )
endif() endif()
add_component_dir(testing
util
)
set (ESM_UI ${CMAKE_CURRENT_SOURCE_DIR}/contentselector/contentselector.ui set (ESM_UI ${CMAKE_CURRENT_SOURCE_DIR}/contentselector/contentselector.ui
) )

@ -1,5 +1,5 @@
#ifndef TESTING_UTIL_H #ifndef OPENMW_COMPONENTS_TESTING_UTIL_H
#define TESTING_UTIL_H #define OPENMW_COMPONENTS_TESTING_UTIL_H
#include <filesystem> #include <filesystem>
#include <initializer_list> #include <initializer_list>
@ -13,7 +13,6 @@
namespace TestingOpenMW namespace TestingOpenMW
{ {
inline std::filesystem::path outputFilePath(const std::string name) inline std::filesystem::path outputFilePath(const std::string name)
{ {
std::filesystem::path dir("tests_output"); std::filesystem::path dir("tests_output");
@ -79,6 +78,7 @@ namespace TestingOpenMW
{ {
return createTestVFS(VFS::FileMap(files.begin(), files.end())); return createTestVFS(VFS::FileMap(files.begin(), files.end()));
} }
}
#define EXPECT_ERROR(X, ERR_SUBSTR) \ #define EXPECT_ERROR(X, ERR_SUBSTR) \
try \ try \
@ -86,11 +86,9 @@ namespace TestingOpenMW
X; \ X; \
FAIL() << "Expected error"; \ FAIL() << "Expected error"; \
} \ } \
catch (std::exception & e) \ catch (const std::exception& e) \
{ \ { \
EXPECT_THAT(e.what(), ::testing::HasSubstr(ERR_SUBSTR)); \ EXPECT_THAT(e.what(), ::testing::HasSubstr(ERR_SUBSTR)); \
} }
} #endif
#endif // TESTING_UTIL_H
Loading…
Cancel
Save