Skip to content

Commit

Permalink
[Tests/Script] Replaced most executions by TestUtils::executeLuaScript()
Browse files Browse the repository at this point in the history
- This allowed to run the GC, releasing all unused symbols
  • Loading branch information
Razakhel committed Sep 3, 2024
1 parent 2bcc5cf commit 9c7e01a
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 76 deletions.
4 changes: 2 additions & 2 deletions tests/src/RaZ/Script/LuaAnimation.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaAnimation Skeleton", "[script][lua][animation]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local skeleton = Skeleton.new()
skeleton = Skeleton.new(0)
skeleton = BvhFormat.load(FilePath.new(RAZ_TESTS_ROOT .. "assets/animation/ànîm.bvh"))
Expand Down
16 changes: 8 additions & 8 deletions tests/src/RaZ/Script/LuaAudio.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaAudio AudioSystem", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new()
audioSystem = AudioSystem.new("")
Expand All @@ -21,7 +21,7 @@ TEST_CASE("LuaAudio AudioSystem", "[script][lua][audio]") {
}

TEST_CASE("LuaAudio Listener", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new() -- Initializing the audio device & context, needed before all audio action
local listener = Listener.new()
Expand Down Expand Up @@ -50,7 +50,7 @@ TEST_CASE("LuaAudio Listener", "[script][lua][audio]") {
}

TEST_CASE("LuaAudio Microphone", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local microphone = Microphone.new(AudioFormat.MONO_U8, 8000, 1)
microphone = Microphone.new(AudioFormat.MONO_I16, 8000, 1, "")
Expand All @@ -68,7 +68,7 @@ TEST_CASE("LuaAudio Microphone", "[script][lua][audio]") {
}

TEST_CASE("LuaAudio Sound", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new() -- Initializing the audio device & context, needed before all audio action
local sound = Sound.new()
Expand Down Expand Up @@ -102,7 +102,7 @@ TEST_CASE("LuaAudio Sound", "[script][lua][audio]") {
)"));

#if !defined(RAZ_PLATFORM_EMSCRIPTEN)
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new() -- Initializing the audio device & context, needed before all audio action
local sound = Sound.new()
Expand All @@ -114,7 +114,7 @@ TEST_CASE("LuaAudio Sound", "[script][lua][audio]") {

#if !defined(RAZ_PLATFORM_EMSCRIPTEN)
TEST_CASE("LuaAudio SoundEffect", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new() -- Initializing the audio device & context, needed before all audio action
local soundEffect = SoundEffect.new()
Expand Down Expand Up @@ -179,7 +179,7 @@ TEST_CASE("LuaAudio SoundEffect", "[script][lua][audio]") {
}

TEST_CASE("LuaAudio SoundEffectSlot", "[script][lua][audio]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local audioSystem = AudioSystem.new() -- Initializing the audio device & context, needed before all audio action
local soundEffectSlot = SoundEffectSlot.new()
Expand Down
14 changes: 7 additions & 7 deletions tests/src/RaZ/Script/LuaCore.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaCore Application", "[script][lua][core]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local frameTimeInfo = FrameTimeInfo.new()
frameTimeInfo.deltaTime = 0
Expand All @@ -30,7 +30,7 @@ TEST_CASE("LuaCore Application", "[script][lua][core]") {
}

TEST_CASE("LuaCore Entity", "[script][lua][core]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local entity = Entity.new(0)
entity = Entity.new(0, true)
Expand Down Expand Up @@ -67,7 +67,7 @@ TEST_CASE("LuaCore Entity", "[script][lua][core]") {
)"));

#if defined(RAZ_USE_AUDIO)
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local entity = Entity.new(0)
entity:addComponent(Listener.new())
Expand All @@ -83,7 +83,7 @@ TEST_CASE("LuaCore Entity", "[script][lua][core]") {
}

TEST_CASE("LuaCore World", "[script][lua][core]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local world = World.new()
world = World.new(0)
Expand All @@ -100,15 +100,15 @@ TEST_CASE("LuaCore World", "[script][lua][core]") {
)"));

#if defined(RAZ_USE_AUDIO)
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local world = World.new()
world:addAudioSystem()
world:addAudioSystem("")
)"));
#endif

#if !defined(RAZ_NO_WINDOW)
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local world = World.new()
-- The constructors with less arguments are not tested to avoid spawning multiple windows
world:addRenderSystem(1, 1, "", WindowSetting.INVISIBLE)
Expand Down
20 changes: 10 additions & 10 deletions tests/src/RaZ/Script/LuaData.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaData Bitset", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local bitset = Bitset.new()
bitset = Bitset.new(1)
bitset = Bitset.new(1, false)
Expand Down Expand Up @@ -33,7 +33,7 @@ TEST_CASE("LuaData Bitset", "[script][lua][data]") {
}

TEST_CASE("LuaData BoundingVolumeHierarchy", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local bvh = BoundingVolumeHierarchy.new()
bvh:build({})
Expand All @@ -57,7 +57,7 @@ TEST_CASE("LuaData BoundingVolumeHierarchy", "[script][lua][data]") {
}

TEST_CASE("LuaData BoundingVolumeHierarchySystem", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local bvhSystem = BoundingVolumeHierarchySystem.new()
assert(bvhSystem:getBvh() ~= nil)
Expand All @@ -70,7 +70,7 @@ TEST_CASE("LuaData BoundingVolumeHierarchySystem", "[script][lua][data]") {
}

TEST_CASE("LuaData Color", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
assert(Color.new() == ColorPreset.Black)
assert(Color.new(Vec3f.new(1, 0, 0)) == ColorPreset.Red)
assert(Color.new(0, 1, 0) == ColorPreset.Green)
Expand All @@ -83,7 +83,7 @@ TEST_CASE("LuaData Color", "[script][lua][data]") {
}

TEST_CASE("LuaData Image", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local img = Image.new()
img = Image.new(ImageColorspace.GRAY)
img = Image.new(ImageColorspace.GRAY_ALPHA, ImageDataType.BYTE)
Expand Down Expand Up @@ -115,7 +115,7 @@ TEST_CASE("LuaData Image", "[script][lua][data]") {
}

TEST_CASE("LuaData Mesh", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local mesh = Mesh.new()
mesh = Mesh.new(Plane.new(0), 0, 0)
mesh = Mesh.new(Sphere.new(Vec3f.new(), 1), 1, SphereMeshType.UV)
Expand Down Expand Up @@ -144,7 +144,7 @@ TEST_CASE("LuaData Mesh", "[script][lua][data]") {
)"));

#if defined(RAZ_USE_FBX)
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local fbxPath = FilePath.new(RAZ_TESTS_ROOT .. "../assets/meshes/shaderBall.fbx")
local meshData, _ = MeshFormat.load(fbxPath)
Expand All @@ -157,7 +157,7 @@ TEST_CASE("LuaData Mesh", "[script][lua][data]") {
}

TEST_CASE("LuaData MeshDistanceField", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local mdf = MeshDistanceField.new(AABB.new(Vec3f.new(), Vec3f.new()), 2, 2, 2)
assert(mdf:getDistance(0, 0, 0) ~= 0)
Expand All @@ -168,7 +168,7 @@ TEST_CASE("LuaData MeshDistanceField", "[script][lua][data]") {
}

TEST_CASE("LuaData Submesh", "[script][lua][data]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local submesh = Submesh.new()
assert(submesh:getVertices():empty())
Expand Down
18 changes: 9 additions & 9 deletions tests/src/RaZ/Script/LuaMath.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaMath Angle", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local deg = Degreesf.new(180)
assert(-deg == Degreesf.new(-180))
assert(deg + 180 == Degreesf.new(360))
Expand All @@ -23,7 +23,7 @@ TEST_CASE("LuaMath Angle", "[script][lua][math]") {
}

TEST_CASE("LuaMath MathUtils", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
assert(MathUtils.lerp(1, 2, 0.25) == 1.25)
assert(MathUtils.lerp(Vec3f.new(1), Vec3f.new(2), 0.25) == Vec3f.new(1.25))
Expand All @@ -36,7 +36,7 @@ TEST_CASE("LuaMath MathUtils", "[script][lua][math]") {
}

TEST_CASE("LuaMath Matrix", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local mat2 = Mat2f.new()
mat2 = Mat2f.new(Mat3f.identity())
mat2 = Mat2f.new(1, 2,
Expand Down Expand Up @@ -183,7 +183,7 @@ TEST_CASE("LuaMath Matrix", "[script][lua][math]") {
}

TEST_CASE("LuaMath PerlinNoise", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
assert(FloatUtils.areNearlyEqual(PerlinNoise.compute1D(0.1), -0.106848))
assert(FloatUtils.areNearlyEqual(PerlinNoise.compute1D(0.1, 2), -0.224224))
assert(FloatUtils.areNearlyEqual(PerlinNoise.compute1D(0.1, 2, true), 0.387888))
Expand All @@ -199,7 +199,7 @@ TEST_CASE("LuaMath PerlinNoise", "[script][lua][math]") {
}

TEST_CASE("LuaMath Quaternion", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local quat = Quaternionf.new(1, 0, 0, 0)
quat = Quaternionf.identity()
quat = Quaternionf.new(Degreesf.new(180), Axis.Y)
Expand Down Expand Up @@ -234,7 +234,7 @@ TEST_CASE("LuaMath Quaternion", "[script][lua][math]") {
}

TEST_CASE("LuaMath Transform", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local trans = Transform.new()
trans = Transform.new(Vec3f.new())
trans = Transform.new(Vec3f.new(), Quaternionf.identity())
Expand Down Expand Up @@ -281,7 +281,7 @@ TEST_CASE("LuaMath Transform", "[script][lua][math]") {
}

TEST_CASE("LuaMath Vector byte", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local vec2 = Vec2b.new()
vec2 = Vec2b.new(1)
vec2 = Vec2b.new(1, 2)
Expand Down Expand Up @@ -355,7 +355,7 @@ TEST_CASE("LuaMath Vector byte", "[script][lua][math]") {
}

TEST_CASE("LuaMath Vector float", "[script][lua][math]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local vec2 = Vec2f.new()
vec2 = Vec2f.new(1)
vec2 = Vec2f.new(1, 2)
Expand Down
8 changes: 4 additions & 4 deletions tests/src/RaZ/Script/LuaPhysics.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RaZ/Script/LuaWrapper.hpp"
#include "TestUtils.hpp"

#include <catch2/catch_test_macros.hpp>

TEST_CASE("LuaPhysics Collider", "[script][lua][physics]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local collider = Collider.new()
assert(not collider:hasShape())
Expand All @@ -21,7 +21,7 @@ TEST_CASE("LuaPhysics Collider", "[script][lua][physics]") {
}

TEST_CASE("LuaPhysics PhysicsSystem", "[script][lua][physics]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local physicsSystem = PhysicsSystem.new()
physicsSystem.gravity = Axis.Y
Expand All @@ -37,7 +37,7 @@ TEST_CASE("LuaPhysics PhysicsSystem", "[script][lua][physics]") {
}

TEST_CASE("LuaPhysics RigidBody", "[script][lua][physics]") {
CHECK(Raz::LuaWrapper::execute(R"(
CHECK(TestUtils::executeLuaScript(R"(
local rigidBody = RigidBody.new(0, 0)
rigidBody.mass = 10
Expand Down
Loading

0 comments on commit 9c7e01a

Please sign in to comment.