From 69f6ab288208f7d088985329f21be5dfe2dd9d53 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Mon, 12 Jun 2023 16:20:36 +0200 Subject: [PATCH] Add integration test for `core.getGMST` --- scripts/data/integration_tests/test_lua_api/openmw.cfg | 6 ++++++ scripts/data/integration_tests/test_lua_api/test.lua | 8 ++++++++ scripts/integration_tests.py | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 scripts/data/integration_tests/test_lua_api/openmw.cfg diff --git a/scripts/data/integration_tests/test_lua_api/openmw.cfg b/scripts/data/integration_tests/test_lua_api/openmw.cfg new file mode 100644 index 0000000000..68e50644a0 --- /dev/null +++ b/scripts/data/integration_tests/test_lua_api/openmw.cfg @@ -0,0 +1,6 @@ +content=test.omwscripts + +# Needed to test `core.getGMST` +fallback=Water_RippleFrameCount,4 +fallback=Inventory_DirectionalDiffuseR,0.5 +fallback=Level_Up_Level2,something diff --git a/scripts/data/integration_tests/test_lua_api/test.lua b/scripts/data/integration_tests/test_lua_api/test.lua index 5929712a33..5aed9bca9b 100644 --- a/scripts/data/integration_tests/test_lua_api/test.lua +++ b/scripts/data/integration_tests/test_lua_api/test.lua @@ -51,6 +51,13 @@ local function testTeleport() testing.expectEqualWithDelta(player.rotation.z, math.rad(-90), 0.05, 'teleporting changes rotation') end +local function testGetGMST() + testing.expectEqual(core.getGMST('non-existed gmst'), nil) + testing.expectEqual(core.getGMST('Water_RippleFrameCount'), 4) + testing.expectEqual(core.getGMST('Inventory_DirectionalDiffuseR'), 0.5) + testing.expectEqual(core.getGMST('Level_Up_Level2'), 'something') +end + local function initPlayer() player:teleport('', util.vector3(4096, 4096, 867.237), util.vector3(0, 0, 0)) coroutine.yield() @@ -83,6 +90,7 @@ tests = { testing.runLocalTest(player, 'castNavigationRay') end}, {'teleport', testTeleport}, + {'getGMST', testGetGMST}, } return { diff --git a/scripts/integration_tests.py b/scripts/integration_tests.py index 54dc17b75e..da2b9aa7fe 100755 --- a/scripts/integration_tests.py +++ b/scripts/integration_tests.py @@ -51,7 +51,9 @@ def runTest(name): "content=template.omwgame\n", ) ) - if (test_dir / "test.omwscripts").exists(): + if (test_dir / "openmw.cfg").exists(): + omw_cfg.write(open(test_dir / "openmw.cfg").read()) + elif (test_dir / "test.omwscripts").exists(): omw_cfg.write("content=test.omwscripts\n") with open(config_dir / "settings.cfg", "a", encoding="utf-8") as settings_cfg: settings_cfg.write(