Merge lp:~larsu/indicator-datetime/remove-test-warnings into lp:indicator-datetime/15.10

Proposed by Lars Karlitski
Status: Superseded
Proposed branch: lp:~larsu/indicator-datetime/remove-test-warnings
Merge into: lp:indicator-datetime/15.10
Prerequisite: lp:~laney/indicator-datetime/timedated-timezone-property
Diff against target: 125 lines (+13/-44)
4 files modified
tests/CMakeLists.txt (+1/-0)
tests/glib-fixture.h (+9/-41)
tests/test-timezone-file.cpp (+2/-2)
tests/test-utils.cpp (+1/-1)
To merge this branch: bzr merge lp:~larsu/indicator-datetime/remove-test-warnings
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Indicator Applet Developers Pending
Review via email: mp+270067@code.launchpad.net

This proposal supersedes a proposal from 2015-09-03.

This proposal has been superseded by a proposal from 2015-09-03.

Description of the change

Remove warnings from test logs

Swallow the ones that are expected and fail the test if they don't show up. In addition, fail tests if unexpected warnings show up again.

Also remove some dead code that dealt with counting log emissions.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
426. By Lars Karlitski

timezone-timedated: subscribe to PropertiesChanged directly

This avoids some unnecessary calls that GDBusProxy makes and the name
watching.

427. By Lars Karlitski

test-utils: don't pass NULL as gsettings string value

NULL is not a valid string. Use the empty string instead.

428. By Lars Karlitski

glib-fixture: fail tests on unexpected warnings

This requires specifying which warnings are expected to be thrown (only
test-timezone-file needed this for now).

However, only fail on warnings in the Indicator-Datetime log domain so
that we don't fail on gstreamer (or other library) warnings for now.

429. By Lars Karlitski

state-fixture: use TestDBusFixture for system bus

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/CMakeLists.txt'
2--- tests/CMakeLists.txt 2015-07-22 12:00:11 +0000
3+++ tests/CMakeLists.txt 2015-09-03 15:12:23 +0000
4@@ -38,6 +38,7 @@
5
6
7 add_definitions (-DSANDBOX="${CMAKE_CURRENT_BINARY_DIR}")
8+add_definitions (-DG_LOG_DOMAIN="Indicator-Datetime")
9
10 function(add_test_by_name name)
11 set (TEST_NAME ${name})
12
13=== modified file 'tests/glib-fixture.h'
14--- tests/glib-fixture.h 2014-09-17 16:51:51 +0000
15+++ tests/glib-fixture.h 2015-09-03 15:12:23 +0000
16@@ -36,34 +36,6 @@
17
18 virtual ~GlibFixture() =default;
19
20- private:
21-
22- //GLogFunc realLogHandler;
23-
24- protected:
25-
26- std::map<GLogLevelFlags,int> logCounts;
27-
28- void testLogCount(GLogLevelFlags log_level, int /*expected*/)
29- {
30-#if 0
31- EXPECT_EQ(expected, logCounts[log_level]);
32-#endif
33-
34- logCounts.erase(log_level);
35- }
36-
37- private:
38-
39- static void default_log_handler(const gchar * log_domain,
40- GLogLevelFlags log_level,
41- const gchar * message,
42- gpointer self)
43- {
44- g_print("%s - %d - %s\n", log_domain, (int)log_level, message);
45- static_cast<GlibFixture*>(self)->logCounts[log_level]++;
46- }
47-
48 protected:
49
50 virtual void SetUp() override
51@@ -72,34 +44,30 @@
52
53 loop = g_main_loop_new(nullptr, false);
54
55- //g_log_set_default_handler(default_log_handler, this);
56-
57 // only use local, temporary settings
58 g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));
59 g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));
60 g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);
61
62+ // fail on unexpected messages from this domain
63+ g_log_set_fatal_mask(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING);
64+
65 g_unsetenv("DISPLAY");
66
67 }
68
69 virtual void TearDown() override
70 {
71-#if 0
72- // confirm there aren't any unexpected log messages
73- EXPECT_EQ(0, logCounts[G_LOG_LEVEL_ERROR]);
74- EXPECT_EQ(0, logCounts[G_LOG_LEVEL_CRITICAL]);
75- EXPECT_EQ(0, logCounts[G_LOG_LEVEL_WARNING]);
76- EXPECT_EQ(0, logCounts[G_LOG_LEVEL_MESSAGE]);
77- EXPECT_EQ(0, logCounts[G_LOG_LEVEL_INFO]);
78-#endif
79-
80- // revert to glib's log handler
81- //g_log_set_default_handler(realLogHandler, this);
82+ g_test_assert_expected_messages ();
83
84 g_clear_pointer(&loop, g_main_loop_unref);
85 }
86
87+ void expectLogMessage (const gchar *domain, GLogLevelFlags level, const gchar *pattern)
88+ {
89+ g_test_expect_message (domain, level, pattern);
90+ }
91+
92 private:
93
94 static gboolean
95
96=== modified file 'tests/test-timezone-file.cpp'
97--- tests/test-timezone-file.cpp 2014-09-17 16:51:51 +0000
98+++ tests/test-timezone-file.cpp 2015-09-03 15:12:23 +0000
99@@ -83,11 +83,11 @@
100 remove(TIMEZONE_FILE);
101 ASSERT_FALSE(g_file_test(TIMEZONE_FILE, G_FILE_TEST_EXISTS));
102
103+ expectLogMessage(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*No such file or directory*");
104+ expectLogMessage(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*No such file or directory*");
105 FileTimezone tz(TIMEZONE_FILE);
106- testLogCount(G_LOG_LEVEL_WARNING, 1);
107 }
108
109-
110 /**
111 * Test that timezone-file picks up the initial value
112 */
113
114=== modified file 'tests/test-utils.cpp'
115--- tests/test-utils.cpp 2014-02-02 21:29:29 +0000
116+++ tests/test-utils.cpp 2015-09-03 15:12:23 +0000
117@@ -59,7 +59,7 @@
118 const char* location;
119 const char* expected_name;
120 } beautify_timezone_test_cases[] = {
121- { "America/Chicago", nullptr, "Chicago" },
122+ { "America/Chicago", "", "Chicago" },
123 { "America/Chicago", "America/Chicago", "Chicago" },
124 { "America/Chicago", "America/Chigago Chicago", "Chicago" },
125 { "America/Chicago", "America/Chicago Oklahoma City", "Oklahoma City" },

Subscribers

People subscribed via source and target branches