[glib] Fix g_test_add_vtable



commit 89aa9dbd9871d6f6cffc25ae8cb02e3b764a25b6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 20 03:14:24 2013 -0500

    Fix g_test_add_vtable
    
    This function was creating a test suite for each added
    testcase, when it should have grouped tests according to
    their paths.

 glib/gtestutils.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index c7b7249..ace550d 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1377,6 +1377,15 @@ g_test_create_case (const char       *test_name,
   return tc;
 }
 
+static gint
+find_suite (gconstpointer l, gconstpointer s)
+{
+  const GTestSuite *suite = l;
+  const gchar *str = s;
+
+  return strcmp (suite->name, str);
+}
+
 /**
  * GTestFixtureFunc:
  * @fixture: the test fixture
@@ -1426,8 +1435,18 @@ g_test_add_vtable (const char       *testpath,
         continue;       /* initial or duplicate slash */
       else if (!islast)
         {
-          GTestSuite *csuite = g_test_create_suite (seg);
-          g_test_suite_add_suite (suite, csuite);
+          GSList *l;
+          GTestSuite *csuite;
+          l = g_slist_find_custom (suite->suites, seg, find_suite);
+          if (l)
+            {
+              csuite = l->data;
+            }
+          else
+            {
+              csuite = g_test_create_suite (seg);
+              g_test_suite_add_suite (suite, csuite);
+            }
           suite = csuite;
         }
       else /* islast */



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