diff --git a/tests/test-chat-template.cpp b/tests/test-chat-template.cpp index bf2fe3b2c..628f960b1 100644 --- a/tests/test-chat-template.cpp +++ b/tests/test-chat-template.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using json = nlohmann::ordered_json; @@ -39,9 +40,22 @@ static void assert_equals(const T & expected, const T & actual) { static std::vector find_files(const std::string & folder, const std::string & ext) { std::vector files; - for (const auto & entry : std::__fs::filesystem::directory_iterator(folder)) { - if (entry.path().extension() == ext) - files.push_back(entry.path().string()); + // Note: once we can use C++17 this becomes: + // for (const auto & entry : std::filesystem::directory_iterator(folder)) + // if (entry.path().extension() == ext) files.push_back(entry.path().string()); + DIR* dir = opendir(folder.c_str()); + if (dir != nullptr) { + struct dirent* entry; + while ((entry = readdir(dir)) != nullptr) { + if (entry->d_type == DT_REG) { // If it's a regular file + std::string filename = entry->d_name; + if (filename.length() >= ext.length() && + filename.compare(filename.length() - ext.length(), ext.length(), ext) == 0) { + files.push_back(folder + "/" + filename); + } + } + } + closedir(dir); } return files; }