Merge branch 'unit_tests' into 'master'

Split openmw_test_suite into openmw and components tests

See merge request OpenMW/openmw!4166
pull/3236/head
psi29a 7 months ago
commit 0a7f4e5149

@ -1,11 +1,8 @@
name: CMake
on:
push:
branches:
- 'master'
pull_request:
branches: [ master ]
- push
- pull_request
env:
BUILD_TYPE: RelWithDebInfo
@ -30,13 +27,27 @@ jobs:
max-size: 1000M
- 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
run: make -j3
run: cmake --build . -- -j$(nproc)
- name: Test
run: ./openmw_test_suite
- name: Run components tests
run: ./components-tests
- name: Run OpenMW tests
run: ./openmw-tests
- name: Run OpenMW-CS tests
run: ./openmw-cs-tests
# - name: Install
# shell: bash

@ -69,15 +69,16 @@ Ubuntu_GCC_preprocess:
- df -h
- du -sh .
- cmake --install .
- if [[ "${BUILD_TESTS_ONLY}" ]]; then ./openmw_test_suite --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}" ]]; then ./components-tests --gtest_output="xml:components-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_esm_refid_benchmark; fi
- if [[ "${BUILD_TESTS_ONLY}" && ! "${BUILD_WITH_CODE_COVERAGE}" ]]; then ./openmw_settings_access_benchmark; fi
- ccache -s
- 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
- 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 ..
- df -h
- du -sh build/
@ -422,7 +423,7 @@ Ubuntu_Clang_Tidy_other:
needs:
- Ubuntu_Clang_Tidy_components
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
.Ubuntu_Clang_tests:
@ -645,7 +646,7 @@ macOS14_Xcode15_arm64:
variables:
config: "RelWithDebInfo"
# 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:
tags:
@ -747,7 +748,7 @@ Windows_MSBuild_RelWithDebInfo:
variables:
config: "RelWithDebInfo"
# 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
rules:
# 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
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
declare -a CMAKE_CONF_OPTS=(
-DCMAKE_C_COMPILER="${CC:-/usr/bin/cc}"
@ -46,14 +38,14 @@ fi
if [[ $CI_CLANG_TIDY ]]; then
CMAKE_CONF_OPTS+=(
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*"
-DBUILD_UNITTESTS=ON
-DBUILD_OPENCS_TESTS=ON
-DBUILD_BENCHMARKS=ON
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*"
-DBUILD_COMPONENTS_TESTS=ON
-DBUILD_OPENMW_TESTS=ON
-DBUILD_OPENCS_TESTS=ON
-DBUILD_BENCHMARKS=ON
)
fi
if [[ "${CMAKE_BUILD_TYPE}" ]]; then
CMAKE_CONF_OPTS+=(
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
@ -103,9 +95,10 @@ if [[ "${BUILD_TESTS_ONLY}" ]]; then
-DBUILD_NAVMESHTOOL=OFF \
-DBUILD_BULLETOBJECTTOOL=OFF \
-DBUILD_NIFTEST=OFF \
-DBUILD_UNITTESTS=${BUILD_UNITTESTS} \
-DBUILD_OPENCS_TESTS=${BUILD_UNITTESTS} \
-DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \
-DBUILD_COMPONENTS_TESTS=ON \
-DBUILD_OPENMW_TESTS=ON \
-DBUILD_OPENCS_TESTS=ON \
-DBUILD_BENCHMARKS=ON \
..
elif [[ "${BUILD_OPENMW_ONLY}" ]]; then
${ANALYZE} cmake \

@ -1169,8 +1169,9 @@ if [ "${BUILD_BENCHMARKS}" ]; then
fi
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_OPENMW_TESTS=ON
fi
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_decoder.hpp
apps/openmw/mwsound/sound_output.hpp
apps/openmw_test_suite/esm/test_fixed_string.cpp
apps/openmw_test_suite/files/conversion_tests.cpp
apps/openmw_test_suite/lua/test_async.cpp
apps/openmw_test_suite/lua/test_configuration.cpp
apps/openmw_test_suite/lua/test_l10n.cpp
apps/openmw_test_suite/lua/test_lua.cpp
apps/openmw_test_suite/lua/test_scriptscontainer.cpp
apps/openmw_test_suite/lua/test_serialization.cpp
apps/openmw_test_suite/lua/test_storage.cpp
apps/openmw_test_suite/lua/test_ui_content.cpp
apps/openmw_test_suite/lua/test_utilpackage.cpp
apps/openmw_test_suite/lua/test_inputactions.cpp
apps/openmw_test_suite/lua/test_yaml.cpp
apps/openmw_test_suite/misc/test_endianness.cpp
apps/openmw_test_suite/misc/test_resourcehelpers.cpp
apps/openmw_test_suite/misc/test_stringops.cpp
apps/openmw_test_suite/mwdialogue/test_keywordsearch.cpp
apps/openmw_test_suite/mwscript/test_scripts.cpp
apps/openmw_test_suite/mwscript/test_utils.hpp
apps/openmw_test_suite/mwworld/test_store.cpp
apps/openmw_test_suite/openmw_test_suite.cpp
apps/openmw_test_suite/testing_util.hpp
apps/components_tests/esm/test_fixed_string.cpp
apps/components_tests/files/conversion_tests.cpp
apps/components_tests/lua/test_async.cpp
apps/components_tests/lua/test_configuration.cpp
apps/components_tests/lua/test_l10n.cpp
apps/components_tests/lua/test_lua.cpp
apps/components_tests/lua/test_scriptscontainer.cpp
apps/components_tests/lua/test_serialization.cpp
apps/components_tests/lua/test_storage.cpp
apps/components_tests/lua/test_ui_content.cpp
apps/components_tests/lua/test_utilpackage.cpp
apps/components_tests/lua/test_inputactions.cpp
apps/components_tests/lua/test_yaml.cpp
apps/components_tests/misc/test_endianness.cpp
apps/components_tests/misc/test_resourcehelpers.cpp
apps/components_tests/misc/test_stringops.cpp
apps/openmw_tests/mwdialogue/test_keywordsearch.cpp
apps/openmw_tests/mwscript/test_scripts.cpp
apps/openmw_tests/mwscript/test_utils.hpp
apps/openmw_tests/mwworld/test_store.cpp
components/bsa/bsa_file.cpp
components/bsa/bsa_file.hpp
components/crashcatcher/windows_crashcatcher.cpp

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

@ -39,11 +39,12 @@ option(BUILD_ESMTOOL "Build ESM inspector" ON)
option(BUILD_NIFTEST "Build nif file tester" ON)
option(BUILD_DOCS "Build documentation." 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_NAVMESHTOOL "Build navmesh tool" ON)
option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON)
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)
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)
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(GMock 1.10 REQUIRED)
endif()
@ -642,7 +643,7 @@ endif()
add_subdirectory (components)
# Apps and tools
if (BUILD_OPENMW)
if (BUILD_OPENMW OR BUILD_OPENMW_TESTS)
add_subdirectory( apps/openmw )
endif()
@ -676,11 +677,10 @@ endif()
if (BUILD_NIFTEST)
add_subdirectory(apps/niftest)
endif(BUILD_NIFTEST)
endif()
# UnitTests
if (BUILD_UNITTESTS)
add_subdirectory( apps/openmw_test_suite )
if (BUILD_COMPONENTS_TESTS)
add_subdirectory(apps/components_tests)
endif()
if (BUILD_BENCHMARKS)
@ -692,13 +692,17 @@ if (BUILD_NAVMESHTOOL)
endif()
if (BUILD_BULLETOBJECTTOOL)
add_subdirectory( apps/bulletobjecttool )
add_subdirectory(apps/bulletobjecttool)
endif()
if (BUILD_OPENCS_TESTS)
add_subdirectory(apps/opencs_tests)
endif()
if (BUILD_OPENMW_TESTS)
add_subdirectory(apps/openmw_tests)
endif()
if (WIN32)
if (MSVC)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
@ -780,8 +784,8 @@ if (WIN32)
target_compile_options(openmw-wizard PRIVATE ${WARNINGS})
endif()
if (BUILD_UNITTESTS)
target_compile_options(openmw_test_suite PRIVATE ${WARNINGS})
if (BUILD_COMPONENTS_TESTS)
target_compile_options(components-tests PRIVATE ${WARNINGS})
endif()
if (BUILD_BENCHMARKS)
@ -795,6 +799,14 @@ if (WIN32)
if (BUILD_BULLETOBJECTTOOL)
target_compile_options(openmw-bulletobjecttool PRIVATE ${WARNINGS} ${MT_BUILD})
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)
# 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})
file(GLOB UNITTEST_SRC_FILES
testing_util.hpp
../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
main.cpp
esm/test_fixed_string.cpp
esm/variant.cpp
@ -66,9 +54,6 @@ file(GLOB UNITTEST_SRC_FILES
shader/parselinks.cpp
shader/shadermanager.cpp
../openmw/options.cpp
openmw/options.cpp
sqlite3/db.cpp
sqlite3/request.cpp
sqlite3/statement.cpp
@ -104,19 +89,24 @@ file(GLOB UNITTEST_SRC_FILES
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
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()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_test_suite PRIVATE --coverage)
target_link_libraries(openmw_test_suite gcov)
target_compile_options(components-tests PRIVATE --coverage)
target_link_libraries(components-tests gcov)
endif()
file(DOWNLOAD
@ -125,12 +115,12 @@ file(DOWNLOAD
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"
OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}")
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>
<gtest/gtest.h>

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

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

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

@ -1,15 +1,13 @@
#include "gmock/gmock.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <components/lua/asyncpackage.hpp>
#include <components/lua/luastate.hpp>
#include "../testing_util.hpp"
#include <components/testing/expecterror.hpp>
namespace
{
using namespace testing;
using namespace TestingOpenMW;
struct LuaCoroutineCallbackTest : Test
{

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

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

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

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

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

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

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

@ -6,15 +6,8 @@
#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)
{
#else
GTEST_API_ int main(int argc, char** argv)
{
#endif
const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files"
/ 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>
namespace

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

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

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

@ -26,7 +26,7 @@ namespace
{
std::ifstream file;
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));
std::stringstream buffer;
buffer << file.rdbuf();

@ -196,8 +196,8 @@ if(BUILD_OPENCS)
target_link_libraries(openmw-cs openmw-cs-lib)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-lib PRIVATE --coverage)
target_link_libraries(openmw-cs-lib gcov)
target_compile_options(openmw-cs PRIVATE --coverage)
target_link_libraries(openmw-cs gcov)
endif()
endif()

@ -1,22 +1,25 @@
# local files
set(GAME
main.cpp
set(OPENMW_SOURCES
engine.cpp
options.cpp
)
set(OPENMW_RESOURCES
${CMAKE_SOURCE_DIR}/files/windows/openmw.rc
${CMAKE_SOURCE_DIR}/files/windows/openmw.exe.manifest
)
if (ANDROID)
set(GAME ${GAME} android_main.cpp)
set(OPENMW_SOURCES ${OPENMW_SOURCES} android_main.cpp)
endif()
set(GAME_HEADER
set(OPENMW_HEADERS
doc.hpp
engine.hpp
options.hpp
profile.hpp
)
source_group(game FILES ${GAME} ${GAME_HEADER})
source_group(apps/openmw FILES main.cpp ${OPENMW_SOURCES} ${OPENMW_HEADERS} ${OPENMW_RESOURCES})
add_openmw_dir (mwrender
actors objects renderingmanager animation rotatecontroller sky skyutil npcanimation esm4npcanimation vismask
@ -120,26 +123,41 @@ add_openmw_dir (mwbase
# Main executable
if (NOT ANDROID)
openmw_add_executable(openmw
${OPENMW_FILES}
${GAME} ${GAME_HEADER}
${APPLE_BUNDLE_RESOURCES}
)
else ()
add_library(openmw
SHARED
add_library(openmw-lib STATIC
${OPENMW_FILES}
${GAME} ${GAME_HEADER}
${OPENMW_SOURCES}
)
# Otherwise linker fails with LNK1149 because main.cpp has __declspec(dllexport)
if(NOT WIN32)
set_target_properties(openmw-lib PROPERTIES OUTPUT_NAME openmw)
endif()
endif ()
if(BUILD_OPENMW)
if (ANDROID)
add_library(openmw-lib SHARED
${OPENMW_FILES}
${OPENMW_SOURCES}
)
else()
openmw_add_executable(openmw
${APPLE_BUNDLE_RESOURCES}
${OPENMW_RESOURCES}
main.cpp
)
target_link_libraries(openmw openmw-lib)
endif()
endif()
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
# when we change the backend.
include_directories(
${FFmpeg_INCLUDE_DIRS}
)
target_link_libraries(openmw
target_link_libraries(openmw-lib
# CMake's built-in OSG finder does not use pkgconfig, so we have to
# manually ensure the order is correct for inter-library dependencies.
# This only makes a difference with `-DOPENMW_USE_SYSTEM_OSG=ON -DOSG_STATIC=ON`.
@ -163,7 +181,7 @@ target_link_libraries(openmw
)
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw PRIVATE
target_precompile_headers(openmw-lib PRIVATE
<boost/program_options/options_description.hpp>
<sol/sol.hpp>
@ -191,23 +209,23 @@ endif()
add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON)
if (ANDROID)
target_link_libraries(openmw EGL android log z)
target_link_libraries(openmw-lib EGL android log z)
endif (ANDROID)
if (USE_SYSTEM_TINYXML)
target_link_libraries(openmw ${TinyXML_LIBRARIES})
target_link_libraries(openmw-lib ${TinyXML_LIBRARIES})
endif()
if (NOT UNIX)
target_link_libraries(openmw ${SDL2MAIN_LIBRARY})
target_link_libraries(openmw-lib ${SDL2MAIN_LIBRARY})
endif()
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(openmw-lib ${CMAKE_THREAD_LIBS_INIT})
endif()
if(APPLE)
if(APPLE AND BUILD_OPENMW)
set(BUNDLE_RESOURCES_DIR "${APP_BUNDLE_DIR}/Contents/Resources")
set(OPENMW_RESOURCES_ROOT ${BUNDLE_RESOURCES_DIR})
@ -236,10 +254,14 @@ if(APPLE)
endif(APPLE)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov)
target_compile_options(openmw-lib PRIVATE --coverage)
target_link_libraries(openmw-lib gcov)
if (NOT ANDROID AND BUILD_OPENMW)
target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov)
endif()
endif()
if (WIN32)
if (WIN32 AND BUILD_OPENMW)
INSTALL(TARGETS openmw RUNTIME DESTINATION ".")
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/loadinglistener/loadinglistener.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 "../testing_util.hpp"
namespace MWMechanics
{
SpellList::SpellList(const ESM::RefId& id, int type)
: mId(id)
, mType(type)
{
}
}
static Loading::Listener dummyListener;
/// Base class for tests of ESMStore that rely on external content files to produce the test results

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

@ -0,0 +1,20 @@
#ifndef OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
#define OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <exception>
#define EXPECT_ERROR(X, ERR_SUBSTR) \
try \
{ \
X; \
FAIL() << "Expected error"; \
} \
catch (const std::exception& e) \
{ \
EXPECT_THAT(e.what(), ::testing::HasSubstr(ERR_SUBSTR)); \
}
#endif

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