Skip to content

Commit

Permalink
Fix (workaround) discovering of test zim file on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Apr 15, 2021
1 parent 9adcee7 commit f5454c6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,24 @@ const std::vector<TestFile> getDataFilePath(const std::string& filename, const s
std::vector<TestFile> filePaths;
std::string dataDirPath;
setDataDir(dataDirPath);
auto dataDir = opendir(dataDirPath.c_str());

if (!dataDir) {
return filePaths;
}

if (!category.empty()) {
// We have asked for a particular category.
filePaths.emplace_back(dataDirPath, category, filename);
} else {
#ifdef _WIN32
// We don't have dirent.h in windows.
// If we move to test data out of the repository, we will need a way to discover the data.
// Use a static list of categories for now.
for (auto& category: {"normal", "nons"}) {
filePaths.emplace_back(dataDirPath, category, filename);
}
#else
auto dataDir = opendir(dataDirPath.c_str());

if (!dataDir) {
return filePaths;
}
struct dirent* current = NULL;
while((current = readdir(dataDir))) {
if (current->d_name[0] == '.' || current->d_name[0] == '_') {
Expand All @@ -141,6 +149,7 @@ const std::vector<TestFile> getDataFilePath(const std::string& filename, const s
filePaths.emplace_back(dataDirPath, current->d_name, filename);
}
closedir(dataDir);
#endif
}

return filePaths;
Expand Down

0 comments on commit f5454c6

Please sign in to comment.