mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 07:36:41 +00:00
Put tests output files to a separate dir
This commit is contained in:
parent
ab1be50b86
commit
709d186b8d
15 changed files with 100 additions and 74 deletions
|
@ -6,6 +6,8 @@ if (GTEST_FOUND AND GMOCK_FOUND)
|
||||||
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
|
||||||
|
|
||||||
../openmw/mwworld/store.cpp
|
../openmw/mwworld/store.cpp
|
||||||
../openmw/mwworld/esmstore.cpp
|
../openmw/mwworld/esmstore.cpp
|
||||||
mwworld/test_store.cpp
|
mwworld/test_store.cpp
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
using namespace TestingOpenMW;
|
||||||
using namespace Files;
|
using namespace Files;
|
||||||
|
|
||||||
struct Params
|
struct Params
|
||||||
|
@ -24,7 +27,7 @@ namespace
|
||||||
|
|
||||||
TEST(FilesGetHash, shouldClearErrors)
|
TEST(FilesGetHash, shouldClearErrors)
|
||||||
{
|
{
|
||||||
const std::string fileName = "fileName";
|
const std::string fileName = temporaryFilePath("fileName");
|
||||||
std::string content;
|
std::string content;
|
||||||
std::fill_n(std::back_inserter(content), 1, 'a');
|
std::fill_n(std::back_inserter(content), 1, 'a');
|
||||||
std::istringstream stream(content);
|
std::istringstream stream(content);
|
||||||
|
@ -34,7 +37,7 @@ namespace
|
||||||
|
|
||||||
TEST_P(FilesGetHash, shouldReturnHashForStringStream)
|
TEST_P(FilesGetHash, shouldReturnHashForStringStream)
|
||||||
{
|
{
|
||||||
const std::string fileName = "fileName";
|
const std::string fileName = temporaryFilePath("fileName");
|
||||||
std::string content;
|
std::string content;
|
||||||
std::fill_n(std::back_inserter(content), GetParam().mSize, 'a');
|
std::fill_n(std::back_inserter(content), GetParam().mSize, 'a');
|
||||||
std::istringstream stream(content);
|
std::istringstream stream(content);
|
||||||
|
@ -47,6 +50,7 @@ namespace
|
||||||
std::replace(fileName.begin(), fileName.end(), '/', '_');
|
std::replace(fileName.begin(), fileName.end(), '/', '_');
|
||||||
std::string content;
|
std::string content;
|
||||||
std::fill_n(std::back_inserter(content), GetParam().mSize, 'a');
|
std::fill_n(std::back_inserter(content), GetParam().mSize, 'a');
|
||||||
|
fileName = outputFilePath(fileName);
|
||||||
std::fstream(fileName, std::ios_base::out | std::ios_base::binary)
|
std::fstream(fileName, std::ios_base::out | std::ios_base::binary)
|
||||||
.write(content.data(), static_cast<std::streamsize>(content.size()));
|
.write(content.data(), static_cast<std::streamsize>(content.size()));
|
||||||
const auto stream = Files::openConstrainedFileStream(fileName, 0, content.size());
|
const auto stream = Files::openConstrainedFileStream(fileName, 0, content.size());
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#include <components/resource/imagemanager.hpp>
|
#include <components/resource/imagemanager.hpp>
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include "../lua/testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
TestFile technique_properties(R"(
|
TestingOpenMW::VFSTestFile technique_properties(R"(
|
||||||
fragment main {}
|
fragment main {}
|
||||||
vertex main {}
|
vertex main {}
|
||||||
technique {
|
technique {
|
||||||
|
@ -27,7 +27,7 @@ TestFile technique_properties(R"(
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|
||||||
TestFile rendertarget_properties{R"(
|
TestingOpenMW::VFSTestFile rendertarget_properties{R"(
|
||||||
render_target rendertarget {
|
render_target rendertarget {
|
||||||
width_ratio = 0.5;
|
width_ratio = 0.5;
|
||||||
height_ratio = 0.5;
|
height_ratio = 0.5;
|
||||||
|
@ -54,7 +54,7 @@ TestFile rendertarget_properties{R"(
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
|
|
||||||
TestFile uniform_properties{R"(
|
TestingOpenMW::VFSTestFile uniform_properties{R"(
|
||||||
uniform_vec4 uVec4 {
|
uniform_vec4 uVec4 {
|
||||||
default = vec4(0,0,0,0);
|
default = vec4(0,0,0,0);
|
||||||
min = vec4(0,1,0,0);
|
min = vec4(0,1,0,0);
|
||||||
|
@ -69,13 +69,13 @@ TestFile uniform_properties{R"(
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
|
|
||||||
TestFile missing_sampler_source{R"(
|
TestingOpenMW::VFSTestFile missing_sampler_source{R"(
|
||||||
sampler_1d mysampler1d { }
|
sampler_1d mysampler1d { }
|
||||||
fragment main { }
|
fragment main { }
|
||||||
technique { passes = main; }
|
technique { passes = main; }
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
TestFile repeated_shared_block{R"(
|
TestingOpenMW::VFSTestFile repeated_shared_block{R"(
|
||||||
shared {
|
shared {
|
||||||
float myfloat = 1.0;
|
float myfloat = 1.0;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ TestFile repeated_shared_block{R"(
|
||||||
std::unique_ptr<Technique> mTechnique;
|
std::unique_ptr<Technique> mTechnique;
|
||||||
|
|
||||||
TechniqueTest()
|
TechniqueTest()
|
||||||
: mVFS(createTestVFS({
|
: mVFS(TestingOpenMW::createTestVFS({
|
||||||
{"shaders/technique_properties.omwfx", &technique_properties},
|
{"shaders/technique_properties.omwfx", &technique_properties},
|
||||||
{"shaders/rendertarget_properties.omwfx", &rendertarget_properties},
|
{"shaders/rendertarget_properties.omwfx", &rendertarget_properties},
|
||||||
{"shaders/uniform_properties.omwfx", &uniform_properties},
|
{"shaders/uniform_properties.omwfx", &uniform_properties},
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <components/lua/configuration.hpp>
|
#include <components/lua/configuration.hpp>
|
||||||
|
|
||||||
#include "testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,17 +6,24 @@
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
#include <components/lua/l10n.hpp>
|
#include <components/lua/l10n.hpp>
|
||||||
|
|
||||||
#include "testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
using namespace TestingOpenMW;
|
||||||
|
|
||||||
TestFile invalidScript("not a script");
|
template <typename T>
|
||||||
TestFile incorrectScript("return { incorrectSection = {}, engineHandlers = { incorrectHandler = function() end } }");
|
T get(sol::state& lua, const std::string& luaCode)
|
||||||
TestFile emptyScript("");
|
{
|
||||||
|
return lua.safe_script("return " + luaCode).get<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
VFSTestFile invalidScript("not a script");
|
||||||
|
VFSTestFile incorrectScript("return { incorrectSection = {}, engineHandlers = { incorrectHandler = function() end } }");
|
||||||
|
VFSTestFile emptyScript("");
|
||||||
|
|
||||||
TestFile test1En(R"X(
|
VFSTestFile test1En(R"X(
|
||||||
good_morning: "Good morning."
|
good_morning: "Good morning."
|
||||||
you_have_arrows: |-
|
you_have_arrows: |-
|
||||||
{count, plural,
|
{count, plural,
|
||||||
|
@ -38,7 +45,7 @@ numbers: "{int} and {double, number, integer} are integers, but {double} is a do
|
||||||
rounding: "{value, number, :: .00}"
|
rounding: "{value, number, :: .00}"
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile test1De(R"X(
|
VFSTestFile test1De(R"X(
|
||||||
good_morning: "Guten Morgen."
|
good_morning: "Guten Morgen."
|
||||||
you_have_arrows: |-
|
you_have_arrows: |-
|
||||||
{count, plural,
|
{count, plural,
|
||||||
|
@ -48,11 +55,11 @@ you_have_arrows: |-
|
||||||
"Hello {name}!": "Hallo {name}!"
|
"Hello {name}!": "Hallo {name}!"
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile test1EnUS(R"X(
|
VFSTestFile test1EnUS(R"X(
|
||||||
currency: "You have {money, number, currency}"
|
currency: "You have {money, number, currency}"
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile test2En(R"X(
|
VFSTestFile test2En(R"X(
|
||||||
good_morning: "Morning!"
|
good_morning: "Morning!"
|
||||||
you_have_arrows: "Arrows count: {count}"
|
you_have_arrows: "Arrows count: {count}"
|
||||||
)X");
|
)X");
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
|
|
||||||
#include "testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
TestFile counterFile(R"X(
|
TestingOpenMW::VFSTestFile counterFile(R"X(
|
||||||
x = 42
|
x = 42
|
||||||
return {
|
return {
|
||||||
get = function() return x end,
|
get = function() return x end,
|
||||||
|
@ -17,9 +17,9 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile invalidScriptFile("Invalid script");
|
TestingOpenMW::VFSTestFile invalidScriptFile("Invalid script");
|
||||||
|
|
||||||
TestFile testsFile(R"X(
|
TestingOpenMW::VFSTestFile testsFile(R"X(
|
||||||
return {
|
return {
|
||||||
-- should work
|
-- should work
|
||||||
sin = function(x) return math.sin(x) end,
|
sin = function(x) return math.sin(x) end,
|
||||||
|
@ -53,7 +53,7 @@ return {
|
||||||
|
|
||||||
struct LuaStateTest : Test
|
struct LuaStateTest : Test
|
||||||
{
|
{
|
||||||
std::unique_ptr<VFS::Manager> mVFS = createTestVFS({
|
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({
|
||||||
{"aaa/counter.lua", &counterFile},
|
{"aaa/counter.lua", &counterFile},
|
||||||
{"bbb/tests.lua", &testsFile},
|
{"bbb/tests.lua", &testsFile},
|
||||||
{"invalid.lua", &invalidScriptFile}
|
{"invalid.lua", &invalidScriptFile}
|
||||||
|
|
|
@ -6,17 +6,18 @@
|
||||||
#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 "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
using namespace TestingOpenMW;
|
||||||
|
|
||||||
TestFile invalidScript("not a script");
|
VFSTestFile invalidScript("not a script");
|
||||||
TestFile incorrectScript("return { incorrectSection = {}, engineHandlers = { incorrectHandler = function() end } }");
|
VFSTestFile incorrectScript("return { incorrectSection = {}, engineHandlers = { incorrectHandler = function() end } }");
|
||||||
TestFile emptyScript("");
|
VFSTestFile emptyScript("");
|
||||||
|
|
||||||
TestFile testScript(R"X(
|
VFSTestFile testScript(R"X(
|
||||||
return {
|
return {
|
||||||
engineHandlers = {
|
engineHandlers = {
|
||||||
onUpdate = function(dt) print(' update ' .. tostring(dt)) end,
|
onUpdate = function(dt) print(' update ' .. tostring(dt)) end,
|
||||||
|
@ -30,7 +31,7 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile stopEventScript(R"X(
|
VFSTestFile stopEventScript(R"X(
|
||||||
return {
|
return {
|
||||||
eventHandlers = {
|
eventHandlers = {
|
||||||
Event1 = function(eventData)
|
Event1 = function(eventData)
|
||||||
|
@ -41,7 +42,7 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile loadSaveScript(R"X(
|
VFSTestFile loadSaveScript(R"X(
|
||||||
x = 0
|
x = 0
|
||||||
y = 0
|
y = 0
|
||||||
return {
|
return {
|
||||||
|
@ -67,7 +68,7 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile interfaceScript(R"X(
|
VFSTestFile interfaceScript(R"X(
|
||||||
return {
|
return {
|
||||||
interfaceName = "TestInterface",
|
interfaceName = "TestInterface",
|
||||||
interface = {
|
interface = {
|
||||||
|
@ -77,7 +78,7 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile overrideInterfaceScript(R"X(
|
VFSTestFile overrideInterfaceScript(R"X(
|
||||||
local old = nil
|
local old = nil
|
||||||
local interface = {
|
local interface = {
|
||||||
fn = function(x)
|
fn = function(x)
|
||||||
|
@ -101,7 +102,7 @@ return {
|
||||||
}
|
}
|
||||||
)X");
|
)X");
|
||||||
|
|
||||||
TestFile useInterfaceScript(R"X(
|
VFSTestFile useInterfaceScript(R"X(
|
||||||
local interfaces = require('openmw.interfaces')
|
local interfaces = require('openmw.interfaces')
|
||||||
return {
|
return {
|
||||||
engineHandlers = {
|
engineHandlers = {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <components/misc/endianness.hpp>
|
#include <components/misc/endianness.hpp>
|
||||||
#include <components/misc/color.hpp>
|
#include <components/misc/color.hpp>
|
||||||
|
|
||||||
#include "testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,18 @@
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
#include <components/lua/utilpackage.hpp>
|
#include <components/lua/utilpackage.hpp>
|
||||||
|
|
||||||
#include "testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T get(sol::state& lua, const std::string& luaCode)
|
||||||
|
{
|
||||||
|
return lua.safe_script("return " + luaCode).get<T>();
|
||||||
|
}
|
||||||
|
|
||||||
std::string getAsString(sol::state& lua, std::string luaCode)
|
std::string getAsString(sol::state& lua, std::string luaCode)
|
||||||
{
|
{
|
||||||
return LuaUtil::toString(lua.safe_script("return " + luaCode));
|
return LuaUtil::toString(lua.safe_script("return " + luaCode));
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "components/misc/resourcehelpers.hpp"
|
#include "components/misc/resourcehelpers.hpp"
|
||||||
#include "../lua/testing_util.hpp"
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace Misc::ResourceHelpers;
|
using namespace Misc::ResourceHelpers;
|
||||||
TEST(CorrectSoundPath, wav_files_not_overridden_with_mp3_in_vfs_are_not_corrected)
|
TEST(CorrectSoundPath, wav_files_not_overridden_with_mp3_in_vfs_are_not_corrected)
|
||||||
{
|
{
|
||||||
std::unique_ptr<VFS::Manager> mVFS = createTestVFS({
|
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({
|
||||||
{"sound/bar.wav", nullptr}
|
{"sound/bar.wav", nullptr}
|
||||||
});
|
});
|
||||||
EXPECT_EQ(correctSoundPath("sound/bar.wav", mVFS.get()), "sound/bar.wav");
|
EXPECT_EQ(correctSoundPath("sound/bar.wav", mVFS.get()), "sound/bar.wav");
|
||||||
|
@ -15,7 +15,7 @@ namespace
|
||||||
|
|
||||||
TEST(CorrectSoundPath, wav_files_overridden_with_mp3_in_vfs_are_corrected)
|
TEST(CorrectSoundPath, wav_files_overridden_with_mp3_in_vfs_are_corrected)
|
||||||
{
|
{
|
||||||
std::unique_ptr<VFS::Manager> mVFS = createTestVFS({
|
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({
|
||||||
{"sound/foo.mp3", nullptr}
|
{"sound/foo.mp3", nullptr}
|
||||||
});
|
});
|
||||||
EXPECT_EQ(correctSoundPath("sound/foo.wav", mVFS.get()), "sound/foo.mp3");
|
EXPECT_EQ(correctSoundPath("sound/foo.wav", mVFS.get()), "sound/foo.mp3");
|
||||||
|
@ -23,14 +23,14 @@ namespace
|
||||||
|
|
||||||
TEST(CorrectSoundPath, corrected_path_does_not_check_existence_in_vfs)
|
TEST(CorrectSoundPath, corrected_path_does_not_check_existence_in_vfs)
|
||||||
{
|
{
|
||||||
std::unique_ptr<VFS::Manager> mVFS = createTestVFS({
|
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({
|
||||||
});
|
});
|
||||||
EXPECT_EQ(correctSoundPath("sound/foo.wav", mVFS.get()), "sound/foo.mp3");
|
EXPECT_EQ(correctSoundPath("sound/foo.wav", mVFS.get()), "sound/foo.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CorrectSoundPath, correct_path_normalize_paths)
|
TEST(CorrectSoundPath, correct_path_normalize_paths)
|
||||||
{
|
{
|
||||||
std::unique_ptr<VFS::Manager> mVFS = createTestVFS({
|
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({
|
||||||
});
|
});
|
||||||
EXPECT_EQ(correctSoundPath("sound\\foo.wav", mVFS.get()), "sound/foo.mp3");
|
EXPECT_EQ(correctSoundPath("sound\\foo.wav", mVFS.get()), "sound/foo.mp3");
|
||||||
EXPECT_EQ(correctSoundPath("SOUND\\foo.WAV", mVFS.get()), "SOUND/foo.mp3");
|
EXPECT_EQ(correctSoundPath("SOUND\\foo.WAV", mVFS.get()), "SOUND/foo.mp3");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/esm3/esmreader.hpp>
|
#include <components/esm3/esmreader.hpp>
|
||||||
|
@ -12,6 +11,8 @@
|
||||||
#include "apps/openmw/mwworld/esmstore.hpp"
|
#include "apps/openmw/mwworld/esmstore.hpp"
|
||||||
#include "apps/openmw/mwmechanics/spelllist.hpp"
|
#include "apps/openmw/mwmechanics/spelllist.hpp"
|
||||||
|
|
||||||
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
SpellList::SpellList(const std::string& id, int type) : mId(id), mType(type) {}
|
SpellList::SpellList(const std::string& id, int type) : mId(id), mType(type) {}
|
||||||
|
@ -62,8 +63,6 @@ struct ContentFileTest : public ::testing::Test
|
||||||
("data-local", boost::program_options::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(Files::MaybeQuotedPathContainer::value_type(), ""));
|
("data-local", boost::program_options::value<Files::MaybeQuotedPathContainer::value_type>()->default_value(Files::MaybeQuotedPathContainer::value_type(), ""));
|
||||||
Files::ConfigurationManager::addCommonOptions(desc);
|
Files::ConfigurationManager::addCommonOptions(desc);
|
||||||
|
|
||||||
boost::program_options::notify(variables);
|
|
||||||
|
|
||||||
mConfigurationManager.readConfiguration(variables, desc, true);
|
mConfigurationManager.readConfiguration(variables, desc, true);
|
||||||
|
|
||||||
Files::PathContainer dataDirs, dataLocal;
|
Files::PathContainer dataDirs, dataLocal;
|
||||||
|
@ -73,10 +72,7 @@ struct ContentFileTest : public ::testing::Test
|
||||||
|
|
||||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>());
|
Files::PathContainer::value_type local(variables["data-local"].as<Files::MaybeQuotedPathContainer::value_type>());
|
||||||
if (!local.empty())
|
if (!local.empty())
|
||||||
{
|
|
||||||
boost::filesystem::create_directories(local);
|
|
||||||
dataLocal.push_back(local);
|
dataLocal.push_back(local);
|
||||||
}
|
|
||||||
|
|
||||||
mConfigurationManager.filterOutNonExistingPaths(dataDirs);
|
mConfigurationManager.filterOutNonExistingPaths(dataDirs);
|
||||||
mConfigurationManager.filterOutNonExistingPaths(dataLocal);
|
mConfigurationManager.filterOutNonExistingPaths(dataLocal);
|
||||||
|
@ -109,10 +105,8 @@ TEST_F(ContentFileTest, dialogue_merging_test)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string file = "test_dialogue_merging.txt";
|
const std::string file = TestingOpenMW::outputFilePath("test_dialogue_merging.txt");
|
||||||
|
std::ofstream stream(file);
|
||||||
std::ofstream stream;
|
|
||||||
stream.open(file);
|
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Dialogue>& dialStore = mEsmStore.get<ESM::Dialogue>();
|
const MWWorld::Store<ESM::Dialogue>& dialStore = mEsmStore.get<ESM::Dialogue>();
|
||||||
for (const auto & dial : dialStore)
|
for (const auto & dial : dialStore)
|
||||||
|
@ -191,10 +185,8 @@ TEST_F(ContentFileTest, content_diagnostics_test)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string file = "test_content_diagnostics.txt";
|
const std::string file = TestingOpenMW::outputFilePath("test_content_diagnostics.txt");
|
||||||
|
std::ofstream stream(file);
|
||||||
std::ofstream stream;
|
|
||||||
stream.open(file);
|
|
||||||
|
|
||||||
RUN_TEST_FOR_TYPES(printRecords, mEsmStore, stream);
|
RUN_TEST_FOR_TYPES(printRecords, mEsmStore, stream);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
@ -17,11 +19,11 @@ namespace
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void withSettingsFile( const std::string& content, F&& f)
|
void withSettingsFile( const std::string& content, F&& f)
|
||||||
{
|
{
|
||||||
const auto path = std::string(UnitTest::GetInstance()->current_test_info()->name()) + ".cfg";
|
std::string path = TestingOpenMW::outputFilePath(
|
||||||
|
std::string(UnitTest::GetInstance()->current_test_info()->name()) + ".cfg");
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ofstream stream;
|
std::ofstream stream(path);
|
||||||
stream.open(path);
|
|
||||||
stream << content;
|
stream << content;
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#include <components/settings/shadermanager.hpp>
|
#include <components/settings/shadermanager.hpp>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
@ -14,7 +17,8 @@ namespace
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void withSettingsFile( const std::string& content, F&& f)
|
void withSettingsFile( const std::string& content, F&& f)
|
||||||
{
|
{
|
||||||
const auto path = std::string(UnitTest::GetInstance()->current_test_info()->name()) + ".yaml";
|
std::string path = TestingOpenMW::outputFilePath(
|
||||||
|
std::string(UnitTest::GetInstance()->current_test_info()->name()) + ".yaml");
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ofstream stream;
|
std::ofstream stream;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "../testing_util.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
@ -28,11 +30,11 @@ namespace
|
||||||
template <class F>
|
template <class F>
|
||||||
void withShaderFile(const std::string& suffix, const std::string& content, F&& f)
|
void withShaderFile(const std::string& suffix, const std::string& content, F&& f)
|
||||||
{
|
{
|
||||||
const auto path = UnitTest::GetInstance()->current_test_info()->name() + suffix + ".glsl";
|
std::string path = TestingOpenMW::outputFilePath(
|
||||||
|
std::string(UnitTest::GetInstance()->current_test_info()->name()) + suffix + ".glsl");
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ofstream stream;
|
std::ofstream stream(path);
|
||||||
stream.open(path);
|
|
||||||
stream << content;
|
stream << content;
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,31 @@
|
||||||
#ifndef LUA_TESTING_UTIL_H
|
#ifndef TESTING_UTIL_H
|
||||||
#define LUA_TESTING_UTIL_H
|
#define TESTING_UTIL_H
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sol/sol.hpp>
|
|
||||||
|
|
||||||
#include <components/vfs/archive.hpp>
|
#include <components/vfs/archive.hpp>
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
|
|
||||||
namespace
|
namespace TestingOpenMW
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename T>
|
inline std::string outputFilePath(const std::string name)
|
||||||
T get(sol::state& lua, const std::string& luaCode)
|
|
||||||
{
|
{
|
||||||
return lua.safe_script("return " + luaCode).get<T>();
|
std::filesystem::path dir("tests_output");
|
||||||
|
std::filesystem::create_directory(dir);
|
||||||
|
return (dir / name).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestFile : public VFS::File
|
inline std::string temporaryFilePath(const std::string name)
|
||||||
|
{
|
||||||
|
return (std::filesystem::temp_directory_path() / name).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
class VFSTestFile : public VFS::File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TestFile(std::string content) : mContent(std::move(content)) {}
|
explicit VFSTestFile(std::string content) : mContent(std::move(content)) {}
|
||||||
|
|
||||||
Files::IStreamPtr open() override
|
Files::IStreamPtr open() override
|
||||||
{
|
{
|
||||||
|
@ -35,11 +41,11 @@ namespace
|
||||||
const std::string mContent;
|
const std::string mContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TestData : public VFS::Archive
|
struct VFSTestData : public VFS::Archive
|
||||||
{
|
{
|
||||||
std::map<std::string, VFS::File*> mFiles;
|
std::map<std::string, VFS::File*> mFiles;
|
||||||
|
|
||||||
TestData(std::map<std::string, VFS::File*> files) : mFiles(std::move(files)) {}
|
VFSTestData(std::map<std::string, VFS::File*> files) : mFiles(std::move(files)) {}
|
||||||
|
|
||||||
void listResources(std::map<std::string, VFS::File*>& out, char (*normalize_function) (char)) override
|
void listResources(std::map<std::string, VFS::File*>& out, char (*normalize_function) (char)) override
|
||||||
{
|
{
|
||||||
|
@ -58,7 +64,7 @@ namespace
|
||||||
inline std::unique_ptr<VFS::Manager> createTestVFS(std::map<std::string, VFS::File*> files)
|
inline std::unique_ptr<VFS::Manager> createTestVFS(std::map<std::string, VFS::File*> files)
|
||||||
{
|
{
|
||||||
auto vfs = std::make_unique<VFS::Manager>(true);
|
auto vfs = std::make_unique<VFS::Manager>(true);
|
||||||
vfs->addArchive(new TestData(std::move(files)));
|
vfs->addArchive(new VFSTestData(std::move(files)));
|
||||||
vfs->buildIndex();
|
vfs->buildIndex();
|
||||||
return vfs;
|
return vfs;
|
||||||
}
|
}
|
||||||
|
@ -68,4 +74,4 @@ namespace
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // LUA_TESTING_UTIL_H
|
#endif // TESTING_UTIL_H
|
Loading…
Reference in a new issue