Merge lp:~michihenning/storage-framework/better-gtest-output into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 82
Merged at revision: 83
Proposed branch: lp:~michihenning/storage-framework/better-gtest-output
Merge into: lp:storage-framework/devel
Diff against target: 102 lines (+71/-0)
4 files modified
tests/remote-client/remote-client_test.cpp (+1/-0)
tests/utils/CMakeLists.txt (+1/-0)
tests/utils/gtest_printer.cpp (+39/-0)
tests/utils/gtest_printer.h (+30/-0)
To merge this branch: bzr merge lp:~michihenning/storage-framework/better-gtest-output
Reviewer Review Type Date Requested Status
James Henstridge Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+309714@code.launchpad.net

Commit message

Added custom type ostream operators for gtest so we get decent output when a QString comparison fails.

Description of the change

Added custom type ostream operators for gtest so we get decent output when a QString comparison fails.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:82
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/163/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/929
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/936
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/739/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/739
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/739/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/163/rebuild

review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/remote-client/remote-client_test.cpp'
2--- tests/remote-client/remote-client_test.cpp 2016-10-17 13:01:16 +0000
3+++ tests/remote-client/remote-client_test.cpp 2016-11-01 02:52:56 +0000
4@@ -19,6 +19,7 @@
5 #include <unity/storage/qt/client-api.h>
6
7 #include "MockProvider.h"
8+#include <utils/gtest_printer.h>
9 #include <utils/ProviderFixture.h>
10
11 #include <gtest/gtest.h>
12
13=== modified file 'tests/utils/CMakeLists.txt'
14--- tests/utils/CMakeLists.txt 2016-08-22 04:56:44 +0000
15+++ tests/utils/CMakeLists.txt 2016-11-01 02:52:56 +0000
16@@ -13,6 +13,7 @@
17 add_library(testutils STATIC
18 DBusEnvironment.cpp
19 ProviderFixture.cpp
20+ gtest_printer.cpp
21 ${generated_files}
22 )
23 target_compile_options(testutils PRIVATE ${QTDBUSTEST_DEPS_CFLAGS} ${ONLINEACCOUNTS_DEPS_CFLAGS})
24
25=== added file 'tests/utils/gtest_printer.cpp'
26--- tests/utils/gtest_printer.cpp 1970-01-01 00:00:00 +0000
27+++ tests/utils/gtest_printer.cpp 2016-11-01 02:52:56 +0000
28@@ -0,0 +1,39 @@
29+/*
30+ * Copyright (C) 2015 Canonical Ltd.
31+ *
32+ * This program is free software: you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License version 3 as
34+ * published by the Free Software Foundation.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details.
40+ *
41+ * You should have received a copy of the GNU General Public License
42+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
43+ *
44+ * Authored by: Michi Henning <michi.henning@canonical.com>
45+ */
46+
47+#include "gtest_printer.h"
48+
49+#include <QString>
50+#include <ostream>
51+
52+using namespace std;
53+
54+ostream& operator<<(ostream& stream, const QString& s)
55+{
56+ return stream << s.toUtf8().constData();
57+}
58+
59+ostream& operator<<(ostream& stream, const char* s)
60+{
61+ return std::operator<<(stream, s);
62+}
63+
64+void PrintTo(const QString& s, ostream* stream)
65+{
66+ *stream << s;
67+}
68
69=== added file 'tests/utils/gtest_printer.h'
70--- tests/utils/gtest_printer.h 1970-01-01 00:00:00 +0000
71+++ tests/utils/gtest_printer.h 2016-11-01 02:52:56 +0000
72@@ -0,0 +1,30 @@
73+/*
74+ * Copyright (C) 2015 Canonical Ltd.
75+ *
76+ * This program is free software: you can redistribute it and/or modify
77+ * it under the terms of the GNU General Public License version 3 as
78+ * published by the Free Software Foundation.
79+ *
80+ * This program is distributed in the hope that it will be useful,
81+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
82+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83+ * GNU General Public License for more details.
84+ *
85+ * You should have received a copy of the GNU General Public License
86+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
87+ *
88+ * Authored by: Michi Henning <michi.henning@canonical.com>
89+ */
90+
91+#pragma once
92+
93+#include <iosfwd>
94+
95+class QString;
96+
97+// Helper for gtest to allow us to insert QString into a stream.
98+std::ostream& operator<<(std::ostream& stream, const QString& s);
99+// Needed because the QString version will take precedence over the std:: one
100+std::ostream& operator<<(std::ostream& stream, const char* s);
101+
102+void PrintTo(const QString& s, std::ostream* stream);

Subscribers

People subscribed via source and target branches

to all changes: