[gjs] test-coverage: fix mtime race condition in test



commit 3665d51b4d75b9ce1c6fd41d80f475ff7a867d4e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Jun 23 15:49:30 2015 -0700

    test-coverage: fix mtime race condition in test
    
    This was causing distcheck to fail, and is similar to what other tests
    do.

 test/gjs-test-coverage.cpp |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/test/gjs-test-coverage.cpp b/test/gjs-test-coverage.cpp
index 0b73cfe..ecd6ffc 100644
--- a/test/gjs-test-coverage.cpp
+++ b/test/gjs-test-coverage.cpp
@@ -1605,6 +1605,16 @@ test_coverage_cache_data_in_expected_format(gpointer      fixture_data,
     GjsCoverageCacheFixture                     *fixture = (GjsCoverageCacheFixture *) fixture_data;
     GjsCoverageCacheObjectNotationTableTestData *table_data = (GjsCoverageCacheObjectNotationTableTestData 
*) user_data;
 
+    write_to_file_at_beginning(fixture->base_fixture.temporary_js_script_open_handle, table_data->script);
+    char *cache_in_object_notation = eval_file_for_ast_in_object_notation(fixture->base_fixture.context,
+                                                                          fixture->base_fixture.coverage,
+                                                                          
fixture->base_fixture.temporary_js_script_filename);
+    g_assert(cache_in_object_notation != NULL);
+
+    /* Sleep for a little while to make sure that the new file has a
+     * different mtime */
+    sleep(1);
+
     GTimeVal mtime;
     gboolean successfully_got_mtime = gjs_get_path_mtime(fixture->base_fixture.temporary_js_script_filename,
                                                          &mtime);
@@ -1618,12 +1628,6 @@ test_coverage_cache_data_in_expected_format(gpointer      fixture_data,
                                                                                     
table_data->expected_branches,
                                                                                     
table_data->expected_functions);
 
-    write_to_file_at_beginning(fixture->base_fixture.temporary_js_script_open_handle, table_data->script);
-    char *cache_in_object_notation = eval_file_for_ast_in_object_notation(fixture->base_fixture.context,
-                                                                          fixture->base_fixture.coverage,
-                                                                          
fixture->base_fixture.temporary_js_script_filename);
-    g_assert(cache_in_object_notation != NULL);
-
     g_assert_cmpstr(cache_in_object_notation, ==, expected_cache_object_notation->str);
 
     g_string_free(expected_cache_object_notation, TRUE);


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