mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
tests: no longer clean up state between tests
Since we now run every test in a separate process there is no need to try and avoid state leakage between tests. This removes the code to cleanup all children of the stage and disconnect handlers from the stage paint signal. We now explicitly print a warning if the users tries to run multiple tests in one process.
This commit is contained in:
parent
3570852b02
commit
b24c96189d
@ -11,41 +11,16 @@ void
|
|||||||
test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture,
|
test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture,
|
||||||
gconstpointer data)
|
gconstpointer data)
|
||||||
{
|
{
|
||||||
/* const TestConformSharedState *shared_state = data; */
|
static int counter = 0;
|
||||||
ClutterActor *stage = clutter_stage_get_default ();
|
|
||||||
GList *actors = clutter_container_get_children (CLUTTER_CONTAINER (stage));
|
|
||||||
GList *tmp;
|
|
||||||
guint paint_handler;
|
|
||||||
guint paint_signal;
|
|
||||||
guint n_paint_handlers = 0;
|
|
||||||
|
|
||||||
/* To help reduce leakage between unit tests, we destroy all children of the stage */
|
if (counter != 0)
|
||||||
for (tmp = actors; tmp != NULL; tmp = tmp->next)
|
g_critical ("We don't support running more than one test at a time\n"
|
||||||
{
|
"in a single test run due to the state leakage that often\n"
|
||||||
ClutterActor *leaked_actor = tmp->data;
|
"causes subsequent tests to fail.\n"
|
||||||
|
"\n"
|
||||||
if (g_test_verbose ())
|
"If you want to run all the tests you should run\n"
|
||||||
g_print ("Freeing leaked actor %p\n", leaked_actor);
|
"$ make test-report");
|
||||||
clutter_actor_destroy (leaked_actor);
|
counter++;
|
||||||
}
|
|
||||||
|
|
||||||
/* Some of the tests leave the paint signal connected to the default
|
|
||||||
stage which causes problems for subsequent tests. This forcibly
|
|
||||||
disconnects all paint handlers. We can't use
|
|
||||||
g_signal_handlers_disconnect_matched because for some reason that
|
|
||||||
doesn't let you pass just G_SIGNAL_MATCH_ID. */
|
|
||||||
paint_signal = g_signal_lookup ("paint", CLUTTER_TYPE_ACTOR);
|
|
||||||
while ((paint_handler = g_signal_handler_find (stage,
|
|
||||||
G_SIGNAL_MATCH_ID,
|
|
||||||
paint_signal,
|
|
||||||
0, NULL, NULL, NULL)))
|
|
||||||
{
|
|
||||||
g_signal_handler_disconnect (stage, paint_handler);
|
|
||||||
n_paint_handlers++;
|
|
||||||
}
|
|
||||||
if (g_test_verbose () && n_paint_handlers > 0)
|
|
||||||
g_print ("Disconnecting %i leaked paint handler%s\n",
|
|
||||||
n_paint_handlers, n_paint_handlers == 1 ? "" : "s");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user