Changeset View
Changeset View
Standalone View
Standalone View
source/test_setup.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return sys_ExecutablePathname().Parent()/".."/"data"; | return sys_ExecutablePathname().Parent()/".."/"data"; | ||||
} | } | ||||
// Script-based testing setup: | // Script-based testing setup: | ||||
namespace | namespace | ||||
{ | { | ||||
void script_TS_FAIL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg) | void script_TS_FAIL(const std::wstring& msg) | ||||
{ | { | ||||
TS_FAIL(utf8_from_wstring(msg).c_str()); | TS_FAIL(utf8_from_wstring(msg).c_str()); | ||||
} | } | ||||
} | } | ||||
void ScriptTestSetup(const ScriptInterface& scriptinterface) | void ScriptTestSetup(const ScriptInterface& scriptinterface) | ||||
{ | { | ||||
scriptinterface.RegisterFunction<void, std::wstring, script_TS_FAIL>("TS_FAIL"); | scriptinterface.RegisterGlobalFunction<decltype(&script_TS_FAIL), &script_TS_FAIL>("TS_FAIL"); | ||||
// Load the TS_* function definitions | // Load the TS_* function definitions | ||||
// (We don't use VFS because tests might not have the normal VFS paths loaded) | // (We don't use VFS because tests might not have the normal VFS paths loaded) | ||||
OsPath path = DataDir()/"tests"/"test_setup.js"; | OsPath path = DataDir()/"tests"/"test_setup.js"; | ||||
std::ifstream ifs(OsString(path).c_str()); | std::ifstream ifs(OsString(path).c_str()); | ||||
ENSURE(ifs.good()); | ENSURE(ifs.good()); | ||||
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); | std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); | ||||
bool ok = scriptinterface.LoadScript(L"test_setup.js", content); | bool ok = scriptinterface.LoadScript(L"test_setup.js", content); | ||||
ENSURE(ok); | ENSURE(ok); | ||||
} | } |
Wildfire Games · Phabricator