Skip to content

Commit 9bc9c29

Browse files
authored
MutterTestCase: Explicitly filter expected fatal warning (#2870)
Currently we ignore all fatal warnings but that's not what we want. We only want to ignore a specific fatal warning and make sure unexpected fatal warnings will still fail the tests. This required a fix for a test that only passed because a fatal warning was ignored. The implementation also makes sure to allow custom filtering of more fatal warnings by overriding a virtual method.
1 parent e08f19c commit 9bc9c29

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

tests/MutterTestCase.vala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,25 @@ public abstract class Gala.MutterTestCase : Gala.TestCase {
5656
}
5757

5858
public override void set_up () {
59-
Test.log_set_fatal_handler ((domain, level, message) => {
59+
Test.log_set_fatal_handler (fatal_log_handler);
60+
61+
main_loop = new MainLoop (null, false);
62+
}
63+
64+
/**
65+
* Override this method if you need to ignore certain fatal logs instead
66+
* of manually calling log_set_fatal_handler.
67+
* Also make sure to chain up to this implementation otherwise the test
68+
* will probably fail.
69+
*/
70+
protected virtual bool fatal_log_handler (string? domain, LogLevelFlags level, string message) {
71+
if (domain == "libmutter" && FLAG_FATAL in level && "Failed to connect to colord daemon" in message) {
6072
/* Mutter sends a fatal log when failing to connect to colord but that doesn't matter for us */
61-
Test.message ("Got fatal log, not aborting");
73+
Test.message ("Got expected fatal colord log, not aborting");
6274
return false;
63-
});
75+
}
6476

65-
main_loop = new MainLoop (null, false);
77+
return true;
6678
}
6779

6880
public override void tear_down () {

tests/lib/GestureControllerTest.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ public class Gala.GestureControllerTest : MutterTestCase {
121121
}
122122

123123
public override void tear_down () {
124-
stage.remove_child (target.actor);
124+
if (target != null) {
125+
stage.remove_child (target.actor);
126+
}
125127

126128
backend = null;
127129
controller = null;

0 commit comments

Comments
 (0)