summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llluamanager.cpp18
-rw-r--r--indra/newview/tests/llluamanager_test.cpp33
2 files changed, 40 insertions, 11 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index c95ce9c57b..ccfa08078e 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -32,6 +32,7 @@
#include "llcoros.h"
#include "llerror.h"
#include "lleventcoro.h"
+#include "llsdutil.h"
#include "llviewercontrol.h"
#include "lua_function.h"
#include "lualistener.h"
@@ -338,18 +339,13 @@ void LLRequireResolver::findModule()
fail();
}
- std::vector<fsyspath> lib_paths
+ LLSD lib_paths(gSavedSettings.getLLSD("LuaRequirePath"));
+ LL_DEBUGS("Lua") << "LuaRequirePath = " << lib_paths << LL_ENDL;
+ for (const auto& path : llsd::inArray(lib_paths))
{
- gDirUtilp->getExpandedFilename(LL_PATH_SCRIPTS, "lua", "require"),
-#ifdef LL_TEST
- // Build-time tests don't have the app bundle - use source tree.
- fsyspath(__FILE__).parent_path() / "scripts" / "lua" / "require",
-#endif
- };
-
- for (const auto& path : lib_paths)
- {
- std::string absolutePathOpt = (path / mPathToResolve).u8string();
+ // if path is already absolute, operator/() preserves it
+ auto abspath(fsyspath(gDirUtilp->getAppRODataDir()) / path.asString());
+ std::string absolutePathOpt = (abspath / mPathToResolve).u8string();
if (absolutePathOpt.empty())
luaL_error(L, "error requiring module '%s'", mPathToResolve.u8string().data());
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.