Fix tests on windows

conditional_push_builds
elsid 3 years ago
parent a854a6e04a
commit b5f0057ac9
No known key found for this signature in database
GPG Key ID: D27B8E8D10A2896B

@ -77,17 +77,12 @@ if (GTEST_FOUND AND GMOCK_FOUND)
endif (CMAKE_CL_64)
endif (MSVC)
include(FetchContent)
FetchContent_Declare(example_suite_template_game
URL https://gitlab.com/OpenMW/example-suite/-/raw/8966dab24692555eec720c854fb0f73d108070cd/data/template.omwgame
URL_HASH MD5=bf3691034a38611534c74c3b89a7d2c3
SOURCE_DIR fetched/example_suite_template_game
DOWNLOAD_NO_EXTRACT ON
file(DOWNLOAD
https://gitlab.com/OpenMW/example-suite/-/raw/8966dab24692555eec720c854fb0f73d108070cd/data/template.omwgame
${CMAKE_CURRENT_BINARY_DIR}/data/template.omwgame
EXPECTED_MD5 bf3691034a38611534c74c3b89a7d2c3
)
FetchContent_MakeAvailableExcludeFromAll(example_suite_template_game)
add_custom_target(example_suite_template_game SOURCES fetched/example_suite_template_game/template.omwgame)
add_dependencies(openmw_test_suite example_suite_template_game)
target_compile_definitions(openmw_test_suite PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data")
endif()

@ -1,5 +1,3 @@
#include "settings.hpp"
#include <components/esmloader/load.cpp>
#include <components/files/collections.hpp>
#include <components/files/multidircollection.hpp>
@ -7,16 +5,18 @@
#include <gtest/gtest.h>
#ifndef OPENMW_DATA_DIR
#error "OPENMW_DATA_DIR is not defined"
#endif
namespace
{
using namespace testing;
using namespace EsmLoader;
using EsmLoaderTests::Settings;
struct EsmLoaderTest : Test
{
const boost::filesystem::path mDataDir {Settings::impl().mBasePath / "apps/openmw_test_suite/fetched/example_suite_template_game"};
const Files::PathContainer mDataDirs {{mDataDir.string()}};
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
const Files::Collections mFileCollections {mDataDirs, true};
const std::vector<std::string> mContentFiles {{"template.omwgame"}};
};

@ -1,20 +0,0 @@
#ifndef OPENMW_TEST_SUITE_LOAD_SETTINGS_H
#define OPENMW_TEST_SUITE_LOAD_SETTINGS_H
#include <boost/filesystem/path.hpp>
namespace EsmLoaderTests
{
struct Settings
{
boost::filesystem::path mBasePath;
static Settings& impl()
{
static Settings value;
return value;
}
};
}
#endif

@ -1,9 +1,5 @@
#include "esmloader/settings.hpp"
#include <gtest/gtest.h>
#include <boost/filesystem/path.hpp>
#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
@ -11,7 +7,6 @@ int main(int argc, char **argv) {
#else
GTEST_API_ int main(int argc, char **argv) {
#endif
EsmLoaderTests::Settings::impl().mBasePath = boost::filesystem::path(argv[0]).parent_path();
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -15,7 +15,7 @@ namespace ESM
struct GameSetting;
struct Land;
struct Static;
struct Variant;
class Variant;
}
namespace EsmLoader

@ -7,6 +7,7 @@
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <string>

Loading…
Cancel
Save