Skip to content

Commit

Permalink
Merge pull request #17102 from unknownbrackets/headless
Browse files Browse the repository at this point in the history
Fix automated test assets access on Windows
  • Loading branch information
hrydgard committed Mar 12, 2023
2 parents da17e85 + c127ff4 commit 4b73672
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
34 changes: 24 additions & 10 deletions headless/Headless.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions headless/WindowsHeadlessHost.cpp
Expand Up @@ -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")));
}
Expand Down

0 comments on commit 4b73672

Please sign in to comment.