Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/tests/test_MapGenerator.h
Show All 13 Lines | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "graphics/MapGenerator.h" | #include "graphics/MapGenerator.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "simulation2/system/ComponentTest.h" | #include "simulation2/system/ComponentTest.h" | ||||
#include <atomic> | |||||
class TestMapGenerator : public CxxTest::TestSuite | class TestMapGenerator : public CxxTest::TestSuite | ||||
{ | { | ||||
public: | public: | ||||
void setUp() | void setUp() | ||||
{ | { | ||||
g_VFS = CreateVfs(); | g_VFS = CreateVfs(); | ||||
g_VFS->Mount(L"", DataDir() / "mods" / "mod" / "", VFS_MOUNT_MUST_EXIST); | g_VFS->Mount(L"", DataDir() / "mods" / "mod" / "", VFS_MOUNT_MUST_EXIST); | ||||
g_VFS->Mount(L"", DataDir() / "mods" / "public" / "", VFS_MOUNT_MUST_EXIST, 1); // ignore directory-not-found errors | g_VFS->Mount(L"", DataDir() / "mods" / "public" / "", VFS_MOUNT_MUST_EXIST, 1); // ignore directory-not-found errors | ||||
Show All 17 Lines | void test_mapgen_scripts() | ||||
VfsPaths paths; | VfsPaths paths; | ||||
TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"maps/random/tests/", L"test_*.js", paths)); | TS_ASSERT_OK(vfs::GetPathnames(g_VFS, L"maps/random/tests/", L"test_*.js", paths)); | ||||
for (const VfsPath& path : paths) | for (const VfsPath& path : paths) | ||||
{ | { | ||||
ScriptInterface scriptInterface("Engine", "MapGenerator", g_ScriptContext); | ScriptInterface scriptInterface("Engine", "MapGenerator", g_ScriptContext); | ||||
ScriptTestSetup(scriptInterface); | ScriptTestSetup(scriptInterface); | ||||
CMapGeneratorWorker worker(&scriptInterface); | std::atomic<int> progress; | ||||
worker.InitScriptInterface(0); | MapGenerator::GenerateMap(progress, scriptInterface, path, "{\"Seed\": 0}", true); | ||||
vladislavbelov: Shouldn't `progress` be checked? | |||||
Done Inline ActionsThe test scripts don't call ExportMap. So the result is INVALID_PROGRESS. Should that be checked? phosit: The test scripts don't call `ExportMap`. So the result is `INVALID_PROGRESS`. Should that be… | |||||
Done Inline ActionsIt'd be good to check. vladislavbelov: It'd be good to check. | |||||
scriptInterface.LoadGlobalScriptFile(path); | |||||
} | } | ||||
Not Done Inline ActionsIt follows from the comment that GenerateMap reads the value. That doesn't seem true. Why we can't use INVALID_PROGRESS? vladislavbelov: It follows from the comment that `GenerateMap` reads the value. That doesn't seem true. Why we… | |||||
Done Inline ActionsAfter GenerateMap ran it can't be distinguished from complete or error. phosit: After `GenerateMap` ran it can't be distinguished from complete or error.
In the test it… | |||||
Not Done Inline ActionsI'd replace -1 by INVALID_PROGRESS in the comment. Also in case of "example" it'd be good to match the comments for the function usages. vladislavbelov: I'd replace `-1` by `INVALID_PROGRESS` in the comment. Also in case of "example" it'd be good… | |||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator
Shouldn't progress be checked?