From dc53d739b859d672ee9285315e7b0fe8de550ae9 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Fri, 7 May 2010 17:50:38 +0000 Subject: [PATCH] Make tests clean up after themselves This was SVN commit r7508. --- source/graphics/tests/test_MeshManager.h | 2 +- .../tests/test_CmpTemplateManager.h | 29 ++++++++++++++----- .../simulation2/tests/test_ComponentManager.h | 2 ++ source/simulation2/tests/test_Simulation2.h | 2 ++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/source/graphics/tests/test_MeshManager.h b/source/graphics/tests/test_MeshManager.h index efa15aa3ba..439a2e6ff4 100644 --- a/source/graphics/tests/test_MeshManager.h +++ b/source/graphics/tests/test_MeshManager.h @@ -69,9 +69,9 @@ class TestMeshManager : public CxxTest::TestSuite void deinitVfs() { + g_VFS.reset(); DeleteDirectory(MOD_PATH); DeleteDirectory(CACHE_PATH); - g_VFS.reset(); } void copyFile(const VfsPath& src, const VfsPath& dst) diff --git a/source/simulation2/tests/test_CmpTemplateManager.h b/source/simulation2/tests/test_CmpTemplateManager.h index 93d7463c99..dfd82979cf 100644 --- a/source/simulation2/tests/test_CmpTemplateManager.h +++ b/source/simulation2/tests/test_CmpTemplateManager.h @@ -37,6 +37,8 @@ public: void setUp() { g_VFS = CreateVfs(20 * MiB); + TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); + TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/L"_testcache")); CXeromyces::Startup(); } @@ -44,12 +46,11 @@ public: { CXeromyces::Terminate(); g_VFS.reset(); + DeleteDirectory(DataDir()/L"_testcache"); } void test_LoadTemplate() { - TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); - CSimContext context; CComponentManager man(context); man.LoadComponentTypes(); @@ -93,8 +94,6 @@ public: void test_LoadTemplate_errors() { - TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); - CSimContext context; CComponentManager man(context); man.LoadComponentTypes(); @@ -126,8 +125,6 @@ public: void test_LoadTemplate_multiple() { - TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); - CSimContext context; CComponentManager man(context); man.LoadComponentTypes(); @@ -163,11 +160,29 @@ public: TS_ASSERT(tempMan->LoadTemplate(ent2, L"inherit-broken", -1) == NULL); TS_ASSERT(tempMan->LoadTemplate(ent2, L"inherit-broken", -1) == NULL); } +}; - void test_load_all_DISABLED() // disabled since it's a bit slow +class TestCmpTemplateManager_2 : public CxxTest::TestSuite +{ +public: + void setUp() { + g_VFS = CreateVfs(20 * MiB); TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/public", VFS_MOUNT_MUST_EXIST)); + TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/L"_testcache")); + CXeromyces::Startup(); + } + void tearDown() + { + CXeromyces::Terminate(); + g_VFS.reset(); + DeleteDirectory(DataDir()/L"_testcache"); + } + + // This just attempts loading every public entity, to check there's no validation errors + void test_load_all_DISABLED() // disabled since it's a bit slow and noisy + { CTerrain dummy; CSimulation2 sim(NULL, &dummy); sim.LoadDefaultScripts(); diff --git a/source/simulation2/tests/test_ComponentManager.h b/source/simulation2/tests/test_ComponentManager.h index a5914ee312..bc4ae8721b 100644 --- a/source/simulation2/tests/test_ComponentManager.h +++ b/source/simulation2/tests/test_ComponentManager.h @@ -45,6 +45,7 @@ public: { g_VFS = CreateVfs(20 * MiB); TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); + TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/L"_testcache")); CXeromyces::Startup(); } @@ -52,6 +53,7 @@ public: { CXeromyces::Terminate(); g_VFS.reset(); + DeleteDirectory(DataDir()/L"_testcache"); } void test_Load() diff --git a/source/simulation2/tests/test_Simulation2.h b/source/simulation2/tests/test_Simulation2.h index d1d08dd097..15f9eeea09 100644 --- a/source/simulation2/tests/test_Simulation2.h +++ b/source/simulation2/tests/test_Simulation2.h @@ -43,6 +43,7 @@ public: { g_VFS = CreateVfs(20 * MiB); TS_ASSERT_OK(g_VFS->Mount(L"", DataDir()/L"mods/_test.sim", VFS_MOUNT_MUST_EXIST)); + TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir()/L"_testcache")); CXeromyces::Startup(); } @@ -50,6 +51,7 @@ public: { CXeromyces::Terminate(); g_VFS.reset(); + DeleteDirectory(DataDir()/L"_testcache"); } void test_AddEntity()