summaryrefslogtreecommitdiff
path: root/indra/newview/tests/llluamanager_test.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-07-02 12:09:59 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-07-02 12:09:59 -0400
commitf8357732a108e579c285a76a53c550b8b5c0a153 (patch)
tree0e9f95b04256dde40d5c21822b5e78583d062f82 /indra/newview/tests/llluamanager_test.cpp
parent212868a8c3f803b387da602b6440f69c2c617e40 (diff)
Make require() implementation honor LuaRequirePath setting.
Remove LL_TEST special case from require() code (to search in the viewer's source tree). Instead, make llluamanager_test.cpp append to LuaRequirePath to get the same effect.
Diffstat (limited to 'indra/newview/tests/llluamanager_test.cpp')
-rw-r--r--indra/newview/tests/llluamanager_test.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp
index d3fc70dfd5..55e87acaea 100644
--- a/indra/newview/tests/llluamanager_test.cpp
+++ b/indra/newview/tests/llluamanager_test.cpp
@@ -21,6 +21,7 @@
#include "../llcommon/tests/StringVec.h"
#include "../test/lltut.h"
#include "llapp.h"
+#include "llcontrol.h"
#include "lldate.h"
#include "llevents.h"
#include "lleventcoro.h"
@@ -39,6 +40,8 @@ public:
bool frame() override { return true; }
};
+LLControlGroup gSavedSettings("Global");
+
template <typename CALLABLE>
auto listener(CALLABLE&& callable)
{
@@ -57,6 +60,36 @@ namespace tut
{
struct llluamanager_data
{
+ llluamanager_data()
+ {
+ // Load gSavedSettings from source tree
+ // indra/newview/tests/llluamanager_test.cpp =>
+ // indra/newview
+ auto newview{ fsyspath(__FILE__).parent_path().parent_path() };
+ auto settings{ newview / "app_settings" / "settings.xml" };
+ // true suppresses implicit declare; implicit declare requires
+ // that every variable in settings.xml has a Comment, which many don't.
+ gSavedSettings.loadFromFile(settings.u8string().c_str(), true);
+ // At test time, since we don't have the app bundle available,
+ // extend LuaRequirePath to include the require directory in the
+ // source tree.
+ auto require{ (newview / "scripts" / "lua" / "require").u8string() };
+ auto paths{ gSavedSettings.getLLSD("LuaRequirePath") };
+ bool found = false;
+ for (const auto& path : llsd::inArray(paths))
+ {
+ if (path.asString() == require)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (! found)
+ {
+ paths.append(require);
+ gSavedSettings.setLLSD("LuaRequirePath", paths);
+ }
+ }
// We need an LLApp instance because LLLUAmanager uses coroutines,
// which suspend, and when a coroutine suspends it checks LLApp state,
// and if it's not APP_STATUS_RUNNING the coroutine terminates.