Skip to content

Commit 93b19ba

Browse files
committed
**Replace exit with std::terminate and refine error handling**
Replaced `exit(2)` with `std::terminate` in multiple runners for better error handling consistency. Simplified Task constructor by removing custom terminate handler and directly logging the error on destruction if the function order is incorrect. Removed redundant debug output in `func_test_util.hpp` for cleaner test logic.
1 parent ab2242f commit 93b19ba

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

modules/core/task/include/task.hpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ enum StateOfTesting : uint8_t { kFunc, kPerf };
7070
template <typename InType, typename OutType>
7171
class Task {
7272
public:
73-
explicit Task(StateOfTesting /*state_of_testing*/ = StateOfTesting::kFunc) {
74-
auto custom_terminate = []() {
75-
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT! \n"
76-
"Expected - \"Validation\", \"PreProcessing\", \"Run\", \"PostProcessing\" \n";
77-
std::abort();
78-
};
79-
std::set_terminate(custom_terminate);
80-
functions_order_.clear();
81-
}
73+
explicit Task(StateOfTesting /*state_of_testing*/ = StateOfTesting::kFunc) { functions_order_.clear(); }
8274

8375
// validation of data and validation of task attributes before running
8476
virtual bool Validation() final {
@@ -131,6 +123,8 @@ class Task {
131123

132124
virtual ~Task() {
133125
if (!functions_order_.empty() || !was_worked_) {
126+
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT! \n Expected - \"Validation\", \"PreProcessing\", \"Run\", "
127+
"\"PostProcessing\" \n";
134128
std::terminate();
135129
} else {
136130
functions_order_.clear();

modules/core/util/include/func_test_util.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
5656
ASSERT_TRUE(task_->PreProcessing());
5757
ASSERT_TRUE(task_->Run());
5858
ASSERT_TRUE(task_->PostProcessing());
59-
std::cout << "task_->GetInput() = " << task_->GetInput() << std::endl;
60-
std::cout << "task_->GetOutput() = " << task_->GetOutput() << std::endl;
6159
ASSERT_TRUE(CheckTestOutputData(task_->GetOutput()));
6260
}
6361

tasks/runners/functional.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
3232
"[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n",
3333
rank, "test_suite_name", "test_name", status.MPI_SOURCE, status.MPI_TAG);
3434
MPI_Finalize();
35-
exit(2);
35+
std::terminate();
3636
}
3737

3838
MPI_Barrier(MPI_COMM_WORLD);

tasks/runners/performance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
3232
"[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n",
3333
rank, "test_suite_name", "test_name", status.MPI_SOURCE, status.MPI_TAG);
3434
MPI_Finalize();
35-
exit(2);
35+
std::terminate();
3636
}
3737

3838
MPI_Barrier(MPI_COMM_WORLD);

0 commit comments

Comments
 (0)