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
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-07-22 12:00:11 +0000
+++ tests/CMakeLists.txt 2015-09-03 15:12:23 +0000
@@ -38,6 +38,7 @@
3838
3939
40add_definitions (-DSANDBOX="${CMAKE_CURRENT_BINARY_DIR}")40add_definitions (-DSANDBOX="${CMAKE_CURRENT_BINARY_DIR}")
41add_definitions (-DG_LOG_DOMAIN="Indicator-Datetime")
4142
42function(add_test_by_name name)43function(add_test_by_name name)
43 set (TEST_NAME ${name})44 set (TEST_NAME ${name})
4445
=== modified file 'tests/glib-fixture.h'
--- tests/glib-fixture.h 2014-09-17 16:51:51 +0000
+++ tests/glib-fixture.h 2015-09-03 15:12:23 +0000
@@ -36,34 +36,6 @@
3636
37 virtual ~GlibFixture() =default;37 virtual ~GlibFixture() =default;
3838
39 private:
40
41 //GLogFunc realLogHandler;
42
43 protected:
44
45 std::map<GLogLevelFlags,int> logCounts;
46
47 void testLogCount(GLogLevelFlags log_level, int /*expected*/)
48 {
49#if 0
50 EXPECT_EQ(expected, logCounts[log_level]);
51#endif
52
53 logCounts.erase(log_level);
54 }
55
56 private:
57
58 static void default_log_handler(const gchar * log_domain,
59 GLogLevelFlags log_level,
60 const gchar * message,
61 gpointer self)
62 {
63 g_print("%s - %d - %s\n", log_domain, (int)log_level, message);
64 static_cast<GlibFixture*>(self)->logCounts[log_level]++;
65 }
66
67 protected:39 protected:
6840
69 virtual void SetUp() override41 virtual void SetUp() override
@@ -72,34 +44,30 @@
7244
73 loop = g_main_loop_new(nullptr, false);45 loop = g_main_loop_new(nullptr, false);
7446
75 //g_log_set_default_handler(default_log_handler, this);
76
77 // only use local, temporary settings47 // only use local, temporary settings
78 g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));48 g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));
79 g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));49 g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));
80 g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);50 g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);
8151
52 // fail on unexpected messages from this domain
53 g_log_set_fatal_mask(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING);
54
82 g_unsetenv("DISPLAY");55 g_unsetenv("DISPLAY");
8356
84 }57 }
8558
86 virtual void TearDown() override59 virtual void TearDown() override
87 {60 {
88#if 061 g_test_assert_expected_messages ();
89 // confirm there aren't any unexpected log messages
90 EXPECT_EQ(0, logCounts[G_LOG_LEVEL_ERROR]);
91 EXPECT_EQ(0, logCounts[G_LOG_LEVEL_CRITICAL]);
92 EXPECT_EQ(0, logCounts[G_LOG_LEVEL_WARNING]);
93 EXPECT_EQ(0, logCounts[G_LOG_LEVEL_MESSAGE]);
94 EXPECT_EQ(0, logCounts[G_LOG_LEVEL_INFO]);
95#endif
96
97 // revert to glib's log handler
98 //g_log_set_default_handler(realLogHandler, this);
9962
100 g_clear_pointer(&loop, g_main_loop_unref);63 g_clear_pointer(&loop, g_main_loop_unref);
101 }64 }
10265
66 void expectLogMessage (const gchar *domain, GLogLevelFlags level, const gchar *pattern)
67 {
68 g_test_expect_message (domain, level, pattern);
69 }
70
103 private:71 private:
10472
105 static gboolean73 static gboolean
10674
=== modified file 'tests/test-timezone-file.cpp'
--- tests/test-timezone-file.cpp 2014-09-17 16:51:51 +0000
+++ tests/test-timezone-file.cpp 2015-09-03 15:12:23 +0000
@@ -83,11 +83,11 @@
83 remove(TIMEZONE_FILE);83 remove(TIMEZONE_FILE);
84 ASSERT_FALSE(g_file_test(TIMEZONE_FILE, G_FILE_TEST_EXISTS));84 ASSERT_FALSE(g_file_test(TIMEZONE_FILE, G_FILE_TEST_EXISTS));
8585
86 expectLogMessage(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*No such file or directory*");
87 expectLogMessage(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*No such file or directory*");
86 FileTimezone tz(TIMEZONE_FILE);88 FileTimezone tz(TIMEZONE_FILE);
87 testLogCount(G_LOG_LEVEL_WARNING, 1);
88}89}
8990
90
91/**91/**
92 * Test that timezone-file picks up the initial value92 * Test that timezone-file picks up the initial value
93 */93 */
9494
=== modified file 'tests/test-utils.cpp'
--- tests/test-utils.cpp 2014-02-02 21:29:29 +0000
+++ tests/test-utils.cpp 2015-09-03 15:12:23 +0000
@@ -59,7 +59,7 @@
59 const char* location;59 const char* location;
60 const char* expected_name;60 const char* expected_name;
61 } beautify_timezone_test_cases[] = {61 } beautify_timezone_test_cases[] = {
62 { "America/Chicago", nullptr, "Chicago" },62 { "America/Chicago", "", "Chicago" },
63 { "America/Chicago", "America/Chicago", "Chicago" },63 { "America/Chicago", "America/Chicago", "Chicago" },
64 { "America/Chicago", "America/Chigago Chicago", "Chicago" },64 { "America/Chicago", "America/Chigago Chicago", "Chicago" },
65 { "America/Chicago", "America/Chicago Oklahoma City", "Oklahoma City" },65 { "America/Chicago", "America/Chicago Oklahoma City", "Oklahoma City" },

Subscribers

People subscribed via source and target branches