[gjs/gnome-3-26] coverage: Misc refactors



commit 0e1d86cb319a523fc844194d8082823b7937ce6c
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Sep 23 22:02:46 2017 -0700

    coverage: Misc refactors
    
    - Include default code coverage options in makefile so that branch
      coverage works
    
    - Eliminate some double exceptions being thrown in cache code
    
    - Fix unused parameter in C++ function
    
    - Remove unused constant dealing with binary cache which we don't have
      anymore
    
    - Remove or change some obsolete comments
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788166

 Makefile-test.am           |  1 +
 gjs/coverage.cpp           | 55 ++++++++++------------------------------------
 test/gjs-test-coverage.cpp |  1 +
 3 files changed, 14 insertions(+), 43 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 879363c..e55e8cb 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -337,6 +337,7 @@ JS_LOG_COMPILER = $$LOG_COMPILER $$LOG_FLAGS $(top_builddir)/minijasmine
 
 CODE_COVERAGE_IGNORE_PATTERN = */{include,mfbt,gjs/test,gjs/installed-tests}/*
 CODE_COVERAGE_GENHTML_OPTIONS =                        \
+       $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)        \
        lcov/coverage.lcov                              \
        --prefix $(abs_top_builddir)/lcov/org/gnome/gjs \
        --prefix $(abs_top_builddir)                    \
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index b40e618..136fed9 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -431,21 +431,17 @@ get_array_from_js_value(JSContext             *context,
     if (element_clear_func)
         g_array_set_clear_func(c_side_array, element_clear_func);
 
-    if (JS_GetArrayLength(context, js_array, &js_array_len)) {
-        uint32_t i = 0;
-        JS::RootedValue element(context);
-        for (; i < js_array_len; ++i) {
-            if (!JS_GetElement(context, js_array, i, &element)) {
-                g_array_unref(c_side_array);
-                gjs_throw(context, "Failed to get function names array element %d", i);
-                return false;
-            }
+    if (!JS_GetArrayLength(context, js_array, &js_array_len)) {
+        g_array_unref(c_side_array);
+        return false;
+    }
 
-            if (!(inserter(c_side_array, context, element))) {
-                g_array_unref(c_side_array);
-                gjs_throw(context, "Failed to convert array element %d", i);
-                return false;
-            }
+    JS::RootedValue element(context);
+    for (uint32_t i = 0; i < js_array_len; ++i) {
+        if (!JS_GetElement(context, js_array, i, &element) ||
+            !inserter(c_side_array, context, element)) {
+            g_array_unref(c_side_array);
+            return false;
         }
     }
 
@@ -526,12 +522,12 @@ get_hit_count_and_line_data(JSContext       *cx,
                             int32_t         *line)
 {
     JS::RootedId hit_count_name(cx, gjs_intern_string_to_id(cx, "hitCount"));
-    if (!gjs_object_require_property(cx, obj, "function element",
+    if (!gjs_object_require_property(cx, obj, description,
                                      hit_count_name, hit_count))
         return false;
 
     JS::RootedId line_number_name(cx, gjs_intern_string_to_id(cx, "line"));
-    return gjs_object_require_property(cx, obj, "function_element",
+    return gjs_object_require_property(cx, obj, description,
                                        line_number_name, line);
 }
 
@@ -970,33 +966,6 @@ gjs_get_file_checksum(GFile *file)
     return checksum;
 }
 
-/* The binary data for the cache has the following structure:
- *
- * {
- *     array [ tuple {
- *         string filename;
- *         string? checksum;
- *         tuple? {
- *             mtime_sec;
- *             mtime_usec;
- *         }
- *         array [
- *             int line;
- *         ] executable lines;
- *         array [ tuple {
- *             int branch_point;
- *             array [
- *                 int line;
- *             ] exits;
- *         } branch_info ] branches;
- *         array [ tuple {
- *             int line;
- *             string key;
- *         } function ] functions;
- *     } file ] files;
- */
-const char *COVERAGE_STATISTICS_CACHE_BINARY_DATA_TYPE = "a(sm(xx)msaia(iai)a(is))";
-
 GBytes *
 gjs_serialize_statistics(GjsCoverage *coverage)
 {
diff --git a/test/gjs-test-coverage.cpp b/test/gjs-test-coverage.cpp
index 5ce5d57..f00cfb1 100644
--- a/test/gjs-test-coverage.cpp
+++ b/test/gjs-test-coverage.cpp
@@ -1843,6 +1843,7 @@ test_coverage_cache_invalidation(gpointer      fixture_data,
 
     const gsize expected_len = G_N_ELEMENTS(expected);
     const char *record = line_starting_with(coverage_data_contents, "SF:");
+    g_assert_nonnull(record);
     g_assert(check_coverage_data_for_source_file(expected, expected_len, record));
 
     g_free(script_output_path);


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