From 6c0d64ca6ed87cf043dbeb5366e595a75536cd6b Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Fri, 4 Jul 2025 17:26:51 +0200 Subject: [PATCH 1/4] test: cleanup temporary files --- modules/task/tests/task_tests.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/task/tests/task_tests.cpp b/modules/task/tests/task_tests.cpp index daedf15a0..1ac96fc2e 100644 --- a/modules/task/tests/task_tests.cpp +++ b/modules/task/tests/task_tests.cpp @@ -4,9 +4,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -16,6 +18,18 @@ using namespace ppc::task; +class ScopedFile { + public: + explicit ScopedFile(const std::string& path) : path_(path) {} + ~ScopedFile() { + std::error_code ec; + std::filesystem::remove(path_, ec); + } + + private: + std::string path_; +}; + namespace ppc::test { template @@ -132,6 +146,7 @@ TEST(TaskTest, GetStringTaskType_InvalidFileThrows) { TEST(TaskTest, GetStringTaskType_UnknownType_WithValidFile) { std::string path = "settings_valid.json"; + ScopedFile cleaner(path); std::ofstream file(path); file << R"({"tasks": {"all": "enabled", "stl": "enabled", "omp": "enabled", "mpi": "enabled", "tbb": "enabled", "seq": "enabled"}})"; @@ -141,6 +156,7 @@ TEST(TaskTest, GetStringTaskType_UnknownType_WithValidFile) { TEST(TaskTest, GetStringTaskType_ThrowsOnBadJSON) { std::string path = "bad_settings.json"; + ScopedFile cleaner(path); std::ofstream file(path); file << "{"; file.close(); @@ -149,6 +165,7 @@ TEST(TaskTest, GetStringTaskType_ThrowsOnBadJSON) { TEST(TaskTest, GetStringTaskType_EachType_WithValidFile) { std::string path = "settings_valid_all.json"; + ScopedFile cleaner(path); std::ofstream file(path); file << R"({"tasks": {"all": "enabled", "stl": "enabled", "omp": "enabled", "mpi": "enabled", "tbb": "enabled", "seq": "enabled"}})"; @@ -164,6 +181,7 @@ TEST(TaskTest, GetStringTaskType_EachType_WithValidFile) { TEST(TaskTest, GetStringTaskType_ReturnsUnknown_OnDefault) { std::string path = "settings_valid_unknown.json"; + ScopedFile cleaner(path); std::ofstream file(path); file << R"({"tasks": {"all": "enabled"}})"; file.close(); @@ -174,6 +192,7 @@ TEST(TaskTest, GetStringTaskType_ReturnsUnknown_OnDefault) { TEST(TaskTest, GetStringTaskType_ThrowsIfKeyMissing) { std::string path = "settings_partial.json"; + ScopedFile cleaner(path); std::ofstream file(path); file << R"({"tasks": {"all": "enabled"}})"; file.close(); From a5d8c581a06810f5473e74fdfe522d2d336d187e Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Sat, 5 Jul 2025 12:32:43 +0200 Subject: [PATCH 2/4] tidy --- modules/task/tests/task_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/task/tests/task_tests.cpp b/modules/task/tests/task_tests.cpp index 1ac96fc2e..a9e92ab90 100644 --- a/modules/task/tests/task_tests.cpp +++ b/modules/task/tests/task_tests.cpp @@ -20,7 +20,7 @@ using namespace ppc::task; class ScopedFile { public: - explicit ScopedFile(const std::string& path) : path_(path) {} + explicit ScopedFile(std::string path) : path_(std::move(path)) {} ~ScopedFile() { std::error_code ec; std::filesystem::remove(path_, ec); From 1bdf86163e09153999433bfab897831c983823b9 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Sat, 5 Jul 2025 13:55:22 +0200 Subject: [PATCH 3/4] header --- modules/task/tests/task_tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/task/tests/task_tests.cpp b/modules/task/tests/task_tests.cpp index a9e92ab90..e4605b863 100644 --- a/modules/task/tests/task_tests.cpp +++ b/modules/task/tests/task_tests.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "runners/include/runners.hpp" From 834c265863b16765cf584e617291c00eb0ddf1ba Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Sat, 5 Jul 2025 14:46:52 +0200 Subject: [PATCH 4/4] Update task_tests.cpp --- modules/task/tests/task_tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/task/tests/task_tests.cpp b/modules/task/tests/task_tests.cpp index e4605b863..0dfaafd6e 100644 --- a/modules/task/tests/task_tests.cpp +++ b/modules/task/tests/task_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include