gtestframework.c: fixed testpath matches for automatic root suite.
authorTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:00:43 +0000 (15:00 +0000)
committerTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:00:43 +0000 (15:00 +0000)
svn path=/trunk/; revision=5896

glib/gtestframework.c

index 34ebc70e3784208d60e642031c2979a88488ee27..30e70ddac356603dd0704bee66e65e34e48292a7 100644 (file)
@@ -677,15 +677,20 @@ g_test_run_suite (GTestSuite *suite)
   while (test_paths)
     {
       const char *rest, *path = test_paths->data;
-      guint l, n;
+      guint l, n = strlen (suite->name);
       test_paths = g_slist_delete_link (test_paths, test_paths);
       while (path[0] == '/')
         path++;
+      if (!n) /* root suite, run unconditionally */
+        {
+          n_bad += 0 != g_test_run_suite_internal (suite, path);
+          continue;
+        }
+      /* regular suite, match path */
       rest = strchr (path, '/');
       l = strlen (path);
       l = rest ? MIN (l, rest - path) : l;
-      n = l ? strlen (suite->name) : 0;
-      if (l == n && strncmp (path, suite->name, n) == 0)
+      if (!l || l == n && strncmp (path, suite->name, n) == 0)
         n_bad += 0 != g_test_run_suite_internal (suite, rest ? rest : "");
     }
   return n_bad;