Skip to content

Commit 929ec7d

Browse files
committed
Include settings path in error message and add test
1 parent 81c3284 commit 929ec7d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

modules/core/performance/tests/perf_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@ TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) {
164164
EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error);
165165
}
166166

167+
TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) {
168+
const std::string missing_path = "non_existent_settings.json";
169+
EXPECT_THROW(
170+
try {
171+
GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path);
172+
} catch (const std::runtime_error& e) {
173+
EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos);
174+
throw;
175+
},
176+
std::runtime_error);
177+
}
178+
167179
TEST(GetStringTaskTypeStandaloneTest, ReturnsUnknownForInvalidEnum) {
168180
std::string path = (std::filesystem::temp_directory_path() / "tmp_settings.json").string();
169181
std::ofstream(path) << R"({"tasks":{"seq":"SEQ"}})";

modules/core/task/include/task.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
6464
inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string &settings_file_path) {
6565
std::ifstream file(settings_file_path);
6666
if (!file.is_open()) {
67-
throw std::runtime_error("Failed to open file settings.json");
67+
throw std::runtime_error("Failed to open " + settings_file_path);
6868
}
6969

7070
auto list_settings = ppc::util::InitJSONPtr();

0 commit comments

Comments
 (0)