From eff0846c530cfdb029056cb63ca7e473c71c211f Mon Sep 17 00:00:00 2001
From: Sebastien Gilles <sebastien.gilles@inria.fr>
Date: Mon, 22 Jul 2019 16:23:18 +0200
Subject: [PATCH] #1464 Now test could fail due to a mpi issue.

---
 Changelog.md                        | 4 ++--
 Sources/Test/Utilities/Now/main.cpp | 9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index c767a62c07..7a9928ee1a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -13,7 +13,7 @@ Starting from v18.47, the ticket numbers in bold are those that might break comp
 ## Tests
 
 - Bug #1461: Due to a git mishap, test about PetscVectorIO was buggy (the fix to the bug was unwittingly overwritten...)
-
+- Bug #1464: A test (Utilities/Now) could fail due to racing condition. 
 
 ## External tools
 
@@ -62,7 +62,7 @@ Starting from v18.47, the ticket numbers in bold are those that might break comp
 - Support #1272: Convert the FromVertexMatching test to activate it in the test suite.
 - Support #1457: Set the timeout for each test.
 
-- Bug #1442: Gitlab-CI: the warning check for macOS failed as an alpine Docker image was assumed and a shell runner was actually used	
+- Bug #1442: Gitlab-CI: the warning check for macOS failed as an alpine Docker image was assumed and a shell runner was actually used
 
 ## Scripts
 
diff --git a/Sources/Test/Utilities/Now/main.cpp b/Sources/Test/Utilities/Now/main.cpp
index dd96735be5..923b0b29aa 100644
--- a/Sources/Test/Utilities/Now/main.cpp
+++ b/Sources/Test/Utilities/Now/main.cpp
@@ -55,8 +55,13 @@ BOOST_FIXTURE_TEST_CASE(same_on_all_processors, Fixture)
 
     output_directory += "/Test/Utilities/Now";
 
-    if (!FilesystemNS::Folder::DoExist(output_directory))
-        FilesystemNS::Folder::Create(output_directory, __FILE__, __LINE__);
+    if (mpi.IsRootProcessor())
+    {
+        if (!FilesystemNS::Folder::DoExist(output_directory))
+            FilesystemNS::Folder::Create(output_directory, __FILE__, __LINE__);
+    }
+
+    mpi.Barrier();
 
     std::ofstream out;
     std::ostringstream oconv;
-- 
GitLab