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.
This commit is contained in:
Matthias Clasen 2013-01-20 03:14:24 -05:00
parent 1cd0cf3797
commit 89aa9dbd98

View File

@ -1377,6 +1377,15 @@ g_test_create_case (const char *test_name,
return tc; return tc;
} }
static gint
find_suite (gconstpointer l, gconstpointer s)
{
const GTestSuite *suite = l;
const gchar *str = s;
return strcmp (suite->name, str);
}
/** /**
* GTestFixtureFunc: * GTestFixtureFunc:
* @fixture: the test fixture * @fixture: the test fixture
@ -1426,8 +1435,18 @@ g_test_add_vtable (const char *testpath,
continue; /* initial or duplicate slash */ continue; /* initial or duplicate slash */
else if (!islast) else if (!islast)
{ {
GTestSuite *csuite = g_test_create_suite (seg); GSList *l;
g_test_suite_add_suite (suite, csuite); 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; suite = csuite;
} }
else /* islast */ else /* islast */