Skip to content

Commit

Permalink
[Tests/TestUtils] Added executeLuaScript()
Browse files Browse the repository at this point in the history
- This executes the given script code then runs the garbage collector
  - This incidentally avoids subsequent tests failing for unknown reasons, notably audio ones
  • Loading branch information
Razakhel committed Sep 3, 2024
1 parent 5f2e723 commit 2bcc5cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/include/TestUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
#ifndef RAZ_TESTUTILS_HPP
#define RAZ_TESTUTILS_HPP

#include <string>

namespace Raz { class Window; }

namespace TestUtils {

Raz::Window& getWindow();

bool executeLuaScript(const std::string& code);

} // namespace TestUtils

#endif // RAZ_TESTUTILS_HPP
12 changes: 12 additions & 0 deletions tests/src/TestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "RaZ/Render/Window.hpp"
#endif // RAZ_NO_WINDOW

#if !defined(RAZ_NO_LUA)
#include "RaZ/Script/LuaWrapper.hpp"
#endif // RAZ_NO_LUA

namespace TestUtils {

#if !defined(RAZ_NO_WINDOW)
Expand All @@ -15,4 +19,12 @@ Raz::Window& getWindow() {
}
#endif // RAZ_NO_WINDOW

#if !defined(RAZ_NO_LUA)
bool executeLuaScript(const std::string& code) {
const bool res = Raz::LuaWrapper::execute(code);
Raz::LuaWrapper::collectGarbage();
return res;
}
#endif // RAZ_NO_LUA

} //namespace TestUtils

0 comments on commit 2bcc5cf

Please sign in to comment.