From 929ec7d376a3c4907e22a26b8a6cb02cea25d5f6 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Fri, 20 Jun 2025 07:43:36 +0200 Subject: [PATCH 1/4] Include settings path in error message and add test --- modules/core/performance/tests/perf_tests.cpp | 12 ++++++++++++ modules/core/task/include/task.hpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/core/performance/tests/perf_tests.cpp b/modules/core/performance/tests/perf_tests.cpp index 5226f54f6..ebf78a1fa 100644 --- a/modules/core/performance/tests/perf_tests.cpp +++ b/modules/core/performance/tests/perf_tests.cpp @@ -164,6 +164,18 @@ TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) { EXPECT_THROW_NOLINT(GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path), std::runtime_error); } +TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) { + const std::string missing_path = "non_existent_settings.json"; + EXPECT_THROW( + try { + GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); + } catch (const std::runtime_error& e) { + EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); + throw; + }, + std::runtime_error); +} + TEST(GetStringTaskTypeStandaloneTest, ReturnsUnknownForInvalidEnum) { std::string path = (std::filesystem::temp_directory_path() / "tmp_settings.json").string(); std::ofstream(path) << R"({"tasks":{"seq":"SEQ"}})"; diff --git a/modules/core/task/include/task.hpp b/modules/core/task/include/task.hpp index 512bc9d6c..5a16b9fef 100644 --- a/modules/core/task/include/task.hpp +++ b/modules/core/task/include/task.hpp @@ -64,7 +64,7 @@ inline std::string GetStringTaskStatus(StatusOfTask status_of_task) { inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string &settings_file_path) { std::ifstream file(settings_file_path); if (!file.is_open()) { - throw std::runtime_error("Failed to open file settings.json"); + throw std::runtime_error("Failed to open " + settings_file_path); } auto list_settings = ppc::util::InitJSONPtr(); From f2fd63307f30f6de3d9bf7ad7251c15fa7f2c84a Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Fri, 20 Jun 2025 07:47:02 +0200 Subject: [PATCH 2/4] Fix format --- modules/core/performance/tests/perf_tests.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/core/performance/tests/perf_tests.cpp b/modules/core/performance/tests/perf_tests.cpp index ebf78a1fa..17ba2fea9 100644 --- a/modules/core/performance/tests/perf_tests.cpp +++ b/modules/core/performance/tests/perf_tests.cpp @@ -167,10 +167,7 @@ TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) { TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) { const std::string missing_path = "non_existent_settings.json"; EXPECT_THROW( - try { - GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); - } catch (const std::runtime_error& e) { - EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); + try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); throw; }, std::runtime_error); From 8a5542396e9761587d976b3c37938b9e6dc667b8 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Fri, 20 Jun 2025 08:13:59 +0200 Subject: [PATCH 3/4] Fix format 2 --- modules/core/performance/tests/perf_tests.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/performance/tests/perf_tests.cpp b/modules/core/performance/tests/perf_tests.cpp index 17ba2fea9..3d3d618a5 100644 --- a/modules/core/performance/tests/perf_tests.cpp +++ b/modules/core/performance/tests/perf_tests.cpp @@ -167,7 +167,8 @@ TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) { TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) { const std::string missing_path = "non_existent_settings.json"; EXPECT_THROW( - try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); + try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { + EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); throw; }, std::runtime_error); From a8facfa89a4080ac72298a538ba173573574d65b Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Fri, 20 Jun 2025 08:27:14 +0200 Subject: [PATCH 4/4] NOLINT --- modules/core/performance/tests/perf_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/performance/tests/perf_tests.cpp b/modules/core/performance/tests/perf_tests.cpp index 3d3d618a5..d0a5ee002 100644 --- a/modules/core/performance/tests/perf_tests.cpp +++ b/modules/core/performance/tests/perf_tests.cpp @@ -166,7 +166,7 @@ TEST_NOLINT(GetStringTaskTypeStandaloneTest, ThrowsIfFileMissing) { TEST_NOLINT(GetStringTaskTypeStandaloneTest, ExceptionMessageContainsPath) { const std::string missing_path = "non_existent_settings.json"; - EXPECT_THROW( + EXPECT_THROW_NOLINT( try { GetStringTaskType(ppc::core::TypeOfTask::kSEQ, missing_path); } catch (const std::runtime_error& e) { EXPECT_NE(std::string(e.what()).find(missing_path), std::string::npos); throw;