[folks] tests: Fix a race condition in setting up for EDS tests



commit 5fe655759f0e43a57f77ab4bb910112c09c9cdb9
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Jun 17 09:18:14 2015 +0100

    tests: Fix a race condition in setting up for EDS tests
    
    Previously, we spawned the EDS source registry process, then created a
    .source file to it to use. However, it looks like sometimes it can
    notice the file part-way through us writing to it, load it, then fail to
    parse it.
    
    Fix that by writing out the file before spawning the EDS source registry
    process.

 tests/lib/eds/backend.vala |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/tests/lib/eds/backend.vala b/tests/lib/eds/backend.vala
index 7ec57b5..675fa5c 100644
--- a/tests/lib/eds/backend.vala
+++ b/tests/lib/eds/backend.vala
@@ -158,6 +158,9 @@ public class EdsTest.Backend
           "[Address Book]\n" +
           "BackendName=local\n").printf (this._addressbook_name);
 
+      yield source_file.replace_contents_async (source_file_content.data, null,
+          false, FileCreateFlags.NONE, null, null);
+
       /* Build a SourceRegistry to manage the sources. */
       var source_registry = yield create_source_registry (null);
       this._source_registry = source_registry;
@@ -170,9 +173,7 @@ public class EdsTest.Backend
           this._prepare_source_async.callback ();
         });
 
-      /* Perform the write and then wait for the SourceRegistry to notify. */
-      yield source_file.replace_contents_async (source_file_content.data, null,
-          false, FileCreateFlags.NONE, null, null);
+      /* Wait for the SourceRegistry to notify if it hasn’t already. */
       this._source = source_registry.ref_source (this._addressbook_name);
       if (this._source == null)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]