Skip to content

Commit

Permalink
tests: attempt to find assets for tests run from build subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik committed Sep 28, 2024
1 parent bc3e0c0 commit a072f30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/test-chat-template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ static std::vector<std::string> find_files(const std::string & folder, const std
static std::string read_file(const std::string &path) {
std::ifstream fs(path, std::ios_base::binary);
if (!fs.is_open()) {
fs = std::ifstream("../" + path, std::ios_base::binary);
if (!fs.is_open()) {
throw std::runtime_error("Failed to open file: " + path);
}
throw std::runtime_error("Failed to open file: " + path);
}
fs.seekg(0, std::ios_base::end);
Expand Down
5 changes: 4 additions & 1 deletion tests/test-tool-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ static void assert_equals(const std::string & expected, const std::string & actu
static std::string read_file(const std::string &path) {
std::ifstream fs(path, std::ios_base::binary);
if (!fs.is_open()) {
throw std::runtime_error("Failed to open file: " + path);
fs = std::ifstream("../" + path, std::ios_base::binary);
if (!fs.is_open()) {
throw std::runtime_error("Failed to open file: " + path);
}
}
fs.seekg(0, std::ios_base::end);
auto size = fs.tellg();
Expand Down

0 comments on commit a072f30

Please sign in to comment.