summaryrefslogtreecommitdiff
path: root/indra/llfilesystem/tests/lldir_test.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <118752495+marchcat@users.noreply.github.com>2025-12-04 00:30:33 +0200
committerGitHub <noreply@github.com>2025-12-04 00:30:33 +0200
commit8c134d5a4a9f08a87104530fe910bc39434cacf2 (patch)
treedad5ddf6daf7f5e1bc7b47cd670a99ca73d4c5a1 /indra/llfilesystem/tests/lldir_test.cpp
parent2c3ce8fb8ce3967d957e13d48627b45dd32f0e00 (diff)
parent590f58dbad3dc3db3482dba86bf2619a87a7dad5 (diff)
Merge pull request #5020 from secondlife/marchcat/slua-linux
develop-linux → SLua PV merge
Diffstat (limited to 'indra/llfilesystem/tests/lldir_test.cpp')
-rw-r--r--indra/llfilesystem/tests/lldir_test.cpp135
1 files changed, 44 insertions, 91 deletions
diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp
index d7d57fa86f..a2104d1ef9 100644
--- a/indra/llfilesystem/tests/lldir_test.cpp
+++ b/indra/llfilesystem/tests/lldir_test.cpp
@@ -27,26 +27,15 @@
#include "linden_common.h"
+#include <filesystem>
#include "llstring.h"
#include "tests/StringVec.h"
#include "../lldir.h"
#include "../lldiriterator.h"
#include "../test/lltut.h"
+#include "../test/namedtempfile.h"
#include "stringize.h"
-#include <boost/assign/list_of.hpp>
-
-using boost::assign::list_of;
-
-// We use ensure_equals(..., vec(list_of(...))) not because it's functionally
-// required, but because ensure_equals() knows how to format a StringVec.
-// Turns out that when ensure_equals() displays a test failure with just
-// list_of("string")("another"), you see 'stringanother' vs. '("string",
-// "another")'.
-StringVec vec(const StringVec& v)
-{
- return v;
-}
// For some tests, use a dummy LLDir that uses memory data instead of touching
// the filesystem
@@ -425,23 +414,19 @@ namespace tut
return path;
}
- std::string makeTestDir( const std::string& dirbase )
+ std::string makeTestDir( )
{
- int counter;
- std::string uniqueDir;
- bool foundUnused;
- std::string delim = gDirUtilp->getDirDelimiter();
+ auto p = NamedTempFile::temp_path();
+ std::filesystem::create_directories(p.native());
- for (counter=0, foundUnused=false; !foundUnused; counter++ )
- {
- char counterStr[3];
- snprintf(counterStr, sizeof(counterStr), "%02d", counter);
- uniqueDir = dirbase + counterStr;
- foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) );
- }
- ensure("test directory '" + uniqueDir + "' creation failed", !LLFile::mkdir(uniqueDir));
+ std::string ret = p.string();
+
+ // There's an implicit assumtion all over this code that the returned path ends with "/" (or "\")
- return uniqueDir + delim; // HACK - apparently, the trailing delimiter is needed...
+ if(ret.size() >= 1 && ret[ ret.size()-1 ] != std::filesystem::path::preferred_separator )
+ ret += std::filesystem::path::preferred_separator;
+
+ return ret;
}
static const char* DirScanFilename[5] = { "file1.abc", "file2.abc", "file1.xyz", "file2.xyz", "file1.mno" };
@@ -497,8 +482,9 @@ namespace tut
// Create the same 5 file names of the two directories
- std::string dir1 = makeTestDir(dirTemp + "LLDirIterator");
- std::string dir2 = makeTestDir(dirTemp + "LLDirIterator");
+ std::string dir1 = makeTestDir();
+ std::string dir2 = makeTestDir();
+
std::string dir1files[5];
std::string dir2files[5];
for (int i=0; i<5; i++)
@@ -590,20 +576,18 @@ namespace tut
// top-level directory of a skin isn't localized
ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS),
- vec(list_of("install/skins/default/colors.xml")
- ("user/skins/default/colors.xml")));
+ StringVec{ "install/skins/default/colors.xml", "user/skins/default/colors.xml" });
// We should not have needed to check for skins/default/en. We should
// just "know" that SKINBASE is not localized.
lldir.ensure_not_checked("install/skins/default/en");
ensure_equals(lldir.findSkinnedFilenames(LLDir::TEXTURES, "only_default.jpeg"),
- vec(list_of("install/skins/default/textures/only_default.jpeg")));
+ StringVec{ "install/skins/default/textures/only_default.jpeg" });
// Nor should we have needed to check skins/default/textures/en
// because textures is known not to be localized.
lldir.ensure_not_checked("install/skins/default/textures/en");
- StringVec expected(vec(list_of("install/skins/default/xui/en/strings.xml")
- ("user/skins/default/xui/en/strings.xml")));
+ StringVec expected(StringVec{ "install/skins/default/xui/en/strings.xml", "user/skins/default/xui/en/strings.xml" });
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
expected);
// The first time, we had to probe to find out whether xui was localized.
@@ -616,23 +600,19 @@ namespace tut
lldir.ensure_not_checked("install/skins/default/xui/en");
// localized subdir with "en-us" instead of "en"
- ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"),
- vec(list_of("install/skins/default/html/en-us/welcome.html")));
+ ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"), StringVec{ "install/skins/default/html/en-us/welcome.html" });
lldir.ensure_checked("install/skins/default/html/en");
lldir.ensure_checked("install/skins/default/html/en-us");
lldir.clear_checked();
- ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"),
- vec(list_of("install/skins/default/html/en-us/welcome.html")));
+ ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"), StringVec{ "install/skins/default/html/en-us/welcome.html" });
lldir.ensure_not_checked("install/skins/default/html/en");
lldir.ensure_not_checked("install/skins/default/html/en-us");
- ensure_equals(lldir.findSkinnedFilenames("future", "somefile.txt"),
- vec(list_of("install/skins/default/future/somefile.txt")));
+ ensure_equals(lldir.findSkinnedFilenames("future", "somefile.txt"), StringVec{ "install/skins/default/future/somefile.txt" });
// Test probing for an unrecognized unlocalized future subdir.
lldir.ensure_checked("install/skins/default/future/en");
lldir.clear_checked();
- ensure_equals(lldir.findSkinnedFilenames("future", "somefile.txt"),
- vec(list_of("install/skins/default/future/somefile.txt")));
+ ensure_equals(lldir.findSkinnedFilenames("future", "somefile.txt"), StringVec{ "install/skins/default/future/somefile.txt" });
// Second time it should remember that future is unlocalized.
lldir.ensure_not_checked("install/skins/default/future/en");
@@ -643,8 +623,7 @@ namespace tut
// make the default localization be "en" and allow "en-gb" (or
// whatever) localizations, which would work much more the way you'd
// expect.
- ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"),
- vec(list_of("install/skins/default/html/en-us/welcome.html")));
+ ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"), StringVec{ "install/skins/default/html/en-us/welcome.html" });
/*------------------------ "default", "fr" -------------------------*/
// We start being able to distinguish localized subdirs from
@@ -654,100 +633,74 @@ namespace tut
// pass merge=true to request this filename in all relevant skins
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
- vec(list_of
- ("install/skins/default/xui/en/strings.xml")
- ("install/skins/default/xui/fr/strings.xml")
- ("user/skins/default/xui/en/strings.xml")
- ("user/skins/default/xui/fr/strings.xml")));
+ StringVec{ "install/skins/default/xui/en/strings.xml", "install/skins/default/xui/fr/strings.xml",
+ "user/skins/default/xui/en/strings.xml", "user/skins/default/xui/fr/strings.xml" });
// pass (or default) merge=false to request only most specific skin
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"),
- vec(list_of
- ("user/skins/default/xui/en/strings.xml")
- ("user/skins/default/xui/fr/strings.xml")));
+ StringVec{ "user/skins/default/xui/en/strings.xml", "user/skins/default/xui/fr/strings.xml" });
// Our dummy floater.xml has a user localization (for "fr") but no
// English override. This is a case in which CURRENT_SKIN nonetheless
// returns paths from two different skins.
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "floater.xml"),
- vec(list_of
- ("install/skins/default/xui/en/floater.xml")
- ("user/skins/default/xui/fr/floater.xml")));
+ StringVec{ "install/skins/default/xui/en/floater.xml", "user/skins/default/xui/fr/floater.xml" });
// Our dummy newfile.xml has an English override but no user
// localization. This is another case in which CURRENT_SKIN
// nonetheless returns paths from two different skins.
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "newfile.xml"),
- vec(list_of
- ("user/skins/default/xui/en/newfile.xml")
- ("install/skins/default/xui/fr/newfile.xml")));
+ StringVec{ "user/skins/default/xui/en/newfile.xml", "install/skins/default/xui/fr/newfile.xml" });
ensure_equals(lldir.findSkinnedFilenames("html", "welcome.html"),
- vec(list_of
- ("install/skins/default/html/en-us/welcome.html")
- ("install/skins/default/html/fr/welcome.html")));
+ StringVec{ "install/skins/default/html/en-us/welcome.html", "install/skins/default/html/fr/welcome.html" });
/*------------------------ "default", "zh" -------------------------*/
lldir.setSkinFolder("default", "zh");
// Because strings.xml has only a "fr" override but no "zh" override
// in any skin, the most localized version we can find is "en".
- ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"),
- vec(list_of("user/skins/default/xui/en/strings.xml")));
+ ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"), StringVec{ "user/skins/default/xui/en/strings.xml" });
/*------------------------- "steam", "en" --------------------------*/
lldir.setSkinFolder("steam", "en");
ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS),
- vec(list_of
- ("install/skins/default/colors.xml")
- ("install/skins/steam/colors.xml")
- ("user/skins/default/colors.xml")
- ("user/skins/steam/colors.xml")));
+ StringVec{ "install/skins/default/colors.xml", "install/skins/steam/colors.xml", "user/skins/default/colors.xml",
+ "user/skins/steam/colors.xml" });
ensure_equals(lldir.findSkinnedFilenames(LLDir::TEXTURES, "only_default.jpeg"),
- vec(list_of("install/skins/default/textures/only_default.jpeg")));
+ StringVec{ "install/skins/default/textures/only_default.jpeg" });
ensure_equals(lldir.findSkinnedFilenames(LLDir::TEXTURES, "only_steam.jpeg"),
- vec(list_of("install/skins/steam/textures/only_steam.jpeg")));
+ StringVec{ "install/skins/steam/textures/only_steam.jpeg" });
ensure_equals(lldir.findSkinnedFilenames(LLDir::TEXTURES, "only_user_default.jpeg"),
- vec(list_of("user/skins/default/textures/only_user_default.jpeg")));
+ StringVec{ "user/skins/default/textures/only_user_default.jpeg" });
ensure_equals(lldir.findSkinnedFilenames(LLDir::TEXTURES, "only_user_steam.jpeg"),
- vec(list_of("user/skins/steam/textures/only_user_steam.jpeg")));
+ StringVec{ "user/skins/steam/textures/only_user_steam.jpeg" });
// CURRENT_SKIN
- ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"),
- vec(list_of("user/skins/steam/xui/en/strings.xml")));
+ ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"), StringVec{ "user/skins/steam/xui/en/strings.xml" });
// pass constraint=ALL_SKINS to request this filename in all relevant skins
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
- vec(list_of
- ("install/skins/default/xui/en/strings.xml")
- ("install/skins/steam/xui/en/strings.xml")
- ("user/skins/default/xui/en/strings.xml")
- ("user/skins/steam/xui/en/strings.xml")));
+ StringVec{ "install/skins/default/xui/en/strings.xml", "install/skins/steam/xui/en/strings.xml",
+ "user/skins/default/xui/en/strings.xml", "user/skins/steam/xui/en/strings.xml" });
/*------------------------- "steam", "fr" --------------------------*/
lldir.setSkinFolder("steam", "fr");
// pass CURRENT_SKIN to request only the most specialized files
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml"),
- vec(list_of
- ("user/skins/steam/xui/en/strings.xml")
- ("user/skins/steam/xui/fr/strings.xml")));
+ StringVec{ "user/skins/steam/xui/en/strings.xml", "user/skins/steam/xui/fr/strings.xml" });
// pass ALL_SKINS to request this filename in all relevant skins
ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
- vec(list_of
- ("install/skins/default/xui/en/strings.xml")
- ("install/skins/default/xui/fr/strings.xml")
- ("install/skins/steam/xui/en/strings.xml")
- ("install/skins/steam/xui/fr/strings.xml")
- ("user/skins/default/xui/en/strings.xml")
- ("user/skins/default/xui/fr/strings.xml")
- ("user/skins/steam/xui/en/strings.xml")
- ("user/skins/steam/xui/fr/strings.xml")));
+ StringVec{ "install/skins/default/xui/en/strings.xml", "install/skins/default/xui/fr/strings.xml",
+ "install/skins/steam/xui/en/strings.xml", "install/skins/steam/xui/fr/strings.xml",
+ "user/skins/default/xui/en/strings.xml", "user/skins/default/xui/fr/strings.xml",
+ "user/skins/steam/xui/en/strings.xml", "user/skins/steam/xui/fr/strings.xml" });
}
template<> template<>