@@ -60,6 +60,17 @@ void WorkerTestFailurePrinter::PrintProcessRank() {
60
60
std::cerr << std::format (" [ PROCESS {} ] " , rank);
61
61
}
62
62
63
+ namespace {
64
+ int RunAllTests () {
65
+ auto status = RUN_ALL_TESTS ();
66
+ if (ppc::util::DestructorFailureFlag::Get ()) {
67
+ throw std::runtime_error (
68
+ std::format (" [ ERROR ] Destructor failed with code {}" , ppc::util::DestructorFailureFlag::Get ()));
69
+ }
70
+ return status;
71
+ }
72
+ } // namespace
73
+
63
74
int Init (int argc, char ** argv) {
64
75
const int init_res = MPI_Init (&argc, &argv);
65
76
if (init_res != MPI_SUCCESS) {
@@ -81,12 +92,8 @@ int Init(int argc, char** argv) {
81
92
listeners.Append (new ppc::core::WorkerTestFailurePrinter (std::shared_ptr<::testing::TestEventListener>(listener)));
82
93
}
83
94
listeners.Append (new ppc::core::UnreadMessagesDetector ());
84
- auto status = RUN_ALL_TESTS ();
85
95
86
- if (ppc::util::DestructorFailureFlag::Get ()) {
87
- throw std::runtime_error (
88
- std::format (" [ ERROR ] Destructor failed with code {}" , ppc::util::DestructorFailureFlag::Get ()));
89
- }
96
+ auto status = RunAllTests ();
90
97
91
98
const int finalize_res = MPI_Finalize ();
92
99
if (finalize_res != MPI_SUCCESS) {
@@ -102,12 +109,7 @@ int SimpleInit(int argc, char** argv) {
102
109
tbb::global_control control (tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads ());
103
110
104
111
testing::InitGoogleTest (&argc, argv);
105
- auto status = RUN_ALL_TESTS ();
106
- if (ppc::util::DestructorFailureFlag::Get ()) {
107
- throw std::runtime_error (
108
- std::format (" [ ERROR ] Destructor failed with code {}" , ppc::util::DestructorFailureFlag::Get ()));
109
- }
110
- return status;
112
+ return RunAllTests ();
111
113
}
112
114
113
115
} // namespace ppc::core
0 commit comments