Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/tests/test_scripts.h
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (!VfsDirectoryExists(L"globalscripts/tests/")) | ||||
return; | return; | ||||
} | } | ||||
VfsPaths paths; | VfsPaths paths; | ||||
TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"globalscripts/tests/", L"test_*.js", paths)); | TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"globalscripts/tests/", L"test_*.js", paths)); | ||||
for (const VfsPath& path : paths) | for (const VfsPath& path : paths) | ||||
{ | { | ||||
CSimContext context; | CSimContext context; | ||||
CComponentManager componentManager(context, g_ScriptRuntime, true); | CComponentManager componentManager(context, g_ScriptContext, true); | ||||
ScriptTestSetup(componentManager.GetScriptInterface()); | ScriptTestSetup(componentManager.GetScriptInterface()); | ||||
load_script(componentManager.GetScriptInterface(), path); | load_script(componentManager.GetScriptInterface(), path); | ||||
} | } | ||||
} | } | ||||
void test_scripts() | void test_scripts() | ||||
{ | { | ||||
if (!VfsFileExists(L"simulation/components/tests/setup.js")) | if (!VfsFileExists(L"simulation/components/tests/setup.js")) | ||||
{ | { | ||||
debug_printf("Skipping component scripts tests (can't find binaries/data/mods/public/simulation/components/tests/setup.js)\n"); | debug_printf("Skipping component scripts tests (can't find binaries/data/mods/public/simulation/components/tests/setup.js)\n"); | ||||
return; | return; | ||||
} | } | ||||
VfsPaths paths; | VfsPaths paths; | ||||
TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"simulation/components/tests/", L"test_*.js", paths)); | TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"simulation/components/tests/", L"test_*.js", paths)); | ||||
TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"simulation/helpers/tests/", L"test_*.js", paths)); | TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"simulation/helpers/tests/", L"test_*.js", paths)); | ||||
paths.push_back(VfsPath(L"simulation/components/tests/setup_test.js")); | paths.push_back(VfsPath(L"simulation/components/tests/setup_test.js")); | ||||
for (const VfsPath& path : paths) | for (const VfsPath& path : paths) | ||||
{ | { | ||||
CSimContext context; | CSimContext context; | ||||
CComponentManager componentManager(context, g_ScriptRuntime, true); | CComponentManager componentManager(context, g_ScriptContext, true); | ||||
ScriptTestSetup(componentManager.GetScriptInterface()); | ScriptTestSetup(componentManager.GetScriptInterface()); | ||||
componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadComponentScript> ("LoadComponentScript"); | componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadComponentScript> ("LoadComponentScript"); | ||||
componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadHelperScript> ("LoadHelperScript"); | componentManager.GetScriptInterface().RegisterFunction<void, VfsPath, Script_LoadHelperScript> ("LoadHelperScript"); | ||||
componentManager.LoadComponentTypes(); | componentManager.LoadComponentTypes(); | ||||
load_script(componentManager.GetScriptInterface(), L"simulation/components/tests/setup.js"); | load_script(componentManager.GetScriptInterface(), L"simulation/components/tests/setup.js"); | ||||
load_script(componentManager.GetScriptInterface(), path); | load_script(componentManager.GetScriptInterface(), path); | ||||
} | } | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator