Skip to content

Commit 5ce0b50

Browse files
committed
fixed multiple environment setup message
1 parent b90d8f4 commit 5ce0b50

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

gtest_mpi.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include "gtest_mpi_internal.hpp"
7575

7676
namespace gtest_mpi {
77-
namespace { // no external linkage
77+
namespace { // no external linkage
7878

7979
class MPITestEnvironment : public ::testing::Environment {
8080
public:
@@ -183,6 +183,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestIterationStart(const ::testing::UnitT
183183
// Taken / modified from Googletest
184184
void PrettyMPIUnitTestResultPrinter::OnEnvironmentsSetUpStart(
185185
const ::testing::UnitTest& /*unit_test*/) {
186+
if (rank_ != 0) return;
186187
ColoredPrintf(COLOR_GREEN, "[----------] ");
187188
printf("Global test environment set-up.\n");
188189
fflush(stdout);
@@ -389,7 +390,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestIterationEnd(const ::testing::UnitTes
389390
int num_disabled = unit_test.reportable_disabled_test_count();
390391
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
391392
if (!num_failed_tests_) {
392-
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
393+
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
393394
}
394395
ColoredPrintf(COLOR_YELLOW, " YOU HAVE %d DISABLED %s\n\n", num_disabled,
395396
num_disabled == 1 ? "TEST" : "TESTS");
@@ -407,8 +408,8 @@ void PrettyMPIUnitTestResultPrinter::OnEnvironmentsTearDownStart(
407408
fflush(stdout);
408409
}
409410

410-
} // anonymous namespace
411-
} // namespace gtest_mpi
411+
} // anonymous namespace
412+
} // namespace gtest_mpi
412413

413414
#endif
414415

0 commit comments

Comments
 (0)