Merge pull request #17102 from unknownbrackets/headless

Fix automated test assets access on Windows
This commit is contained in:
Henrik Rydgård 2023-03-12 22:30:25 +01:00 committed by GitHub
commit 4b73672b79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 10 deletions

View file

@ -264,6 +264,28 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const
return passed;
}
std::vector<std::string> ReadFromListFile(const std::string &listFilename) {
std::vector<std::string> testFilenames;
char temp[2048]{};
if (listFilename == "-") {
while (scanf("%2047s", temp) == 1)
testFilenames.push_back(temp);
} else {
FILE *fp = File::OpenCFile(Path(listFilename), "rt");
if (!fp) {
fprintf(stderr, "Unable to open '%s' as a list file\n", listFilename.c_str());
return testFilenames;
}
while (fscanf(fp, "%2047s", temp) == 1)
testFilenames.push_back(temp);
fclose(fp);
}
return testFilenames;
}
int main(int argc, const char* argv[])
{
PROFILE_INIT();
@ -363,16 +385,8 @@ int main(int argc, const char* argv[])
testFilenames.push_back(argv[i]);
}
// TODO: Allow a filename here?
if (testFilenames.size() == 1 && testFilenames[0] == "@-")
{
testFilenames.clear();
char temp[2048];
temp[2047] = '\0';
while (scanf("%2047s", temp) == 1)
testFilenames.push_back(temp);
}
if (testFilenames.size() == 1 && testFilenames[0][0] == '@')
testFilenames = ReadFromListFile(testFilenames[0].substr(1));
if (testFilenames.empty())
return printUsage(argv[0], argc <= 1 ? NULL : "No executables specified");

View file

@ -71,6 +71,7 @@ void WindowsHeadlessHost::LoadNativeAssets()
g_VFS.Register("", new DirectoryReader(Path("assets")));
g_VFS.Register("", new DirectoryReader(Path("")));
g_VFS.Register("", new DirectoryReader(Path("..")));
g_VFS.Register("", new DirectoryReader(Path("../assets")));
g_VFS.Register("", new DirectoryReader(Path("../Windows/assets")));
g_VFS.Register("", new DirectoryReader(Path("../Windows")));
}