Merge lp:~chasedouglas/xorg-gtest/fixes into lp:~oif-team/xorg-gtest/trunk

Proposed by Chase Douglas on 2011-12-14
Status: Merged
Merged at revision: 8
Proposed branch: lp:~chasedouglas/xorg-gtest/fixes
Merge into: lp:~oif-team/xorg-gtest/trunk
Diff against target: 269 lines (+59/-47)
10 files modified
Makefile.am (+8/-1)
configure.ac (+1/-2)
doc/Makefile.am (+6/-6)
examples/Makefile.am (+5/-1)
include/xorg/gtest/environment.h (+6/-4)
include/xorg/gtest/process.h (+23/-21)
include/xorg/gtest/test.h (+5/-6)
m4/gtest.m4 (+3/-4)
src/environment.cpp (+1/-1)
src/process.cpp (+1/-1)
To merge this branch: bzr merge lp:~chasedouglas/xorg-gtest/fixes
Reviewer Review Type Date Requested Status
Thomas Voß (community) 2011-12-14 Approve on 2011-12-15
Review via email: mp+85732@code.launchpad.net

Description of the change

Various fixes

To post a comment you must log in.
lp:~chasedouglas/xorg-gtest/fixes updated on 2011-12-14
7. By Chase Douglas on 2011-12-14

Merge example documentation fixes

Thomas Voß (thomas-voss) wrote :

I like the changes, especially making SetUp and TearDown protected.
Looks good to me.

review: Approve
Chase Douglas (chasedouglas) wrote :

Thomas, please merge this for me in my absence. Thanks!

lp:~chasedouglas/xorg-gtest/fixes updated on 2011-12-16
8. By Thomas Voß on 2011-12-16

Merged in lp:~chasedouglas/xorg-gtest/fixes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2011-12-14 17:13:34 +0000
3+++ Makefile.am 2011-12-14 19:43:29 +0000
4@@ -7,6 +7,10 @@
5 src/process.cpp \
6 src/test.cpp
7
8+libxorg_gtest_la_CPPFLAGS = \
9+ $(AM_CPPFLAGS) \
10+ $(GTEST_CPPFLAGS)
11+
12 libxorg_gtest_main_la_SOURCES = \
13 src/main.cpp
14
15@@ -19,7 +23,10 @@
16 library_datadir = $(datadir)/xorg/gtest
17 library_data_DATA = conf/dummy.conf
18
19-libxorg_gtest_main_la_CPPFLAGS = $(AM_CPPFLAGS) -DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\""
20+libxorg_gtest_main_la_CPPFLAGS = \
21+ $(AM_CPPFLAGS) \
22+ $(GTEST_CPPFLAGS) \
23+ -DDUMMY_CONF_PATH="\"$(library_datadir)/dummy.conf\""
24
25 libxorg_gtest_la_LDFLAGS = $(X11_LIBS)
26 libxorg_gtest_main_la_LDFLAGS = $(X11_LIBS)
27
28=== modified file 'configure.ac'
29--- configure.ac 2011-12-14 17:13:34 +0000
30+++ configure.ac 2011-12-14 19:43:29 +0000
31@@ -34,8 +34,7 @@
32 AS_IF([test "x$ac_cv_lib_gtest_main" != xyes],
33 AC_MSG_ERROR([package 'gtest' not found]))
34
35-AC_SUBST([GTEST_LDFLAGS])
36-AC_SUBST([GTEST_CXXFLAGS])
37+AC_SUBST([GTEST_CPPFLAGS])
38
39 AC_SUBST(DUMMY_CONF_PATH, "$datadir/xorg/gtest/dummy.conf")
40
41
42=== modified file 'doc/Makefile.am'
43--- doc/Makefile.am 2011-12-12 08:22:17 +0000
44+++ doc/Makefile.am 2011-12-14 19:43:29 +0000
45@@ -21,11 +21,9 @@
46 ## <http://www.gnu.org/licenses/>.
47 ##
48
49-dist_doc_DATA = \
50+EXTRA_DIST = \
51 Doxyfile
52
53-# dist_man_MANS = geistest.1
54-
55 doc-html: doc-html-doxygen
56
57 doc-man: doc-man-doxygen
58@@ -41,9 +39,11 @@
59 doc-pdf-doxygen:
60 doxygen
61
62-install-data-local: api/html
63- $(INSTALL) -d $(DESTDIR)$(docdir)
64- cp -a api/html $(DESTDIR)$(docdir)
65+install-data-local:
66+ if [ -d api/html ]; then \
67+ $(INSTALL) -d $(DESTDIR)$(docdir); \
68+ cp -a api/html $(DESTDIR)$(docdir); \
69+ fi
70
71 clean-local:
72 -rm -rf *.pdf *.html api
73
74=== modified file 'examples/Makefile.am'
75--- examples/Makefile.am 2011-12-14 15:19:03 +0000
76+++ examples/Makefile.am 2011-12-14 19:43:29 +0000
77@@ -22,4 +22,8 @@
78
79 xorg_gtest_example_SOURCES = xorg-gtest.cpp
80
81-xorg_gtest_example_LDFLAGS = -lxorg-gtest -lxorg-gtest_main -lgtest -lpthread -lX11
82\ No newline at end of file
83+xorg_gtest_example_CPPFLAGS = \
84+ $(AM_CPPFLAGS) \
85+ $(GTEST_CPPFLAGS)
86+
87+xorg_gtest_example_LDFLAGS = -lxorg-gtest -lxorg-gtest_main -lgtest -lpthread -lX11
88
89=== modified file 'include/xorg/gtest/environment.h'
90--- include/xorg/gtest/environment.h 2011-12-14 15:19:03 +0000
91+++ include/xorg/gtest/environment.h 2011-12-14 19:43:29 +0000
92@@ -71,11 +71,13 @@
93 const std::string& path_to_server = "Xorg", int display = 133);
94
95 virtual ~Environment();
96+
97+ protected:
98 /**
99 * Starts the dummy X server.
100 *
101- * Reimplemented from ::testing::Environment. Should only be called by subclasses.
102- * See Google %Test documentation for details.
103+ * Reimplemented from ::testing::Environment. See Google %Test documentation
104+ * for details.
105 *
106 * @throws std::runtime_error if a dummy X server cannot be started.
107 *
108@@ -88,8 +90,8 @@
109 /**
110 * Stops the dummy X server.
111 *
112- * Reimplemented from ::testing::Environment. Should only be called by subclasses.
113- * See Google %Test documentation for details.
114+ * Reimplemented from ::testing::Environment. See Google %Test documentation
115+ * for details.
116 *
117 * @post Dummy X server stopped.
118 */
119
120=== modified file 'include/xorg/gtest/process.h'
121--- include/xorg/gtest/process.h 2011-12-13 17:33:39 +0000
122+++ include/xorg/gtest/process.h 2011-12-14 19:43:29 +0000
123@@ -56,6 +56,29 @@
124 class Process {
125 public:
126 /**
127+ * Helper function to adjust the environment of the current process.
128+ *
129+ * @param [in] name Name of the environment variable.
130+ * @param [in] value Value of the environment variable.
131+ * @param [in] overwrite Whether to overwrite the value of existing env
132+ * variables.
133+ *
134+ * @throws std::runtime_error if adjusting the environment does not succeed.
135+ */
136+ static void SetEnv(const std::string& name, const std::string& value,
137+ bool overwrite);
138+
139+ /**
140+ * Helper function to query the environment of the current process.
141+ *
142+ * @param [in] name The name of the environment variable.
143+ * @param [out] exists If not NULL, the variable will be set to true if the
144+ * environment variable exists and to false otherwise.
145+ * @returns The value of the environment variable, or an empty string.
146+ */
147+ static std::string GetEnv(const std::string& name, bool* exists = NULL);
148+
149+ /**
150 * Creates a child-process that is in a terminated state.
151 */
152 Process();
153@@ -115,27 +138,6 @@
154 bool Kill();
155
156 /**
157- * Adjusts the environment of the child process.
158- *
159- * @param [in] name Name of the environment variable.
160- * @param [in] value Value of the environment variable.
161- * @param [in] overwrite Whether to overwrite the value of existing env variables.
162- *
163- * @throws std::runtime_error if adjusting the environment does not succeed.
164- */
165- void SetEnv(const std::string& name, const std::string& value, bool overwrite);
166-
167- /**
168- * Queries the environment of the child process.
169- *
170- * @param [in] name The name of the environment variable.
171- * @param [out] exists If not NULL, the variable will be set to true if the
172- * environment variable exists and to false otherwise.
173- * @returns The value of the environment variable, or an empty string.
174- */
175- std::string GetEnv(const std::string& name, bool* exists = NULL) const;
176-
177- /**
178 * Accesses the pid of the child process.
179 *
180 * @returns The pid of the child process or -1.
181
182=== modified file 'include/xorg/gtest/test.h'
183--- include/xorg/gtest/test.h 2011-12-14 15:19:03 +0000
184+++ include/xorg/gtest/test.h 2011-12-14 19:43:29 +0000
185@@ -49,12 +49,13 @@
186
187 virtual ~Test();
188
189+ protected:
190 /**
191 * Tries to connect to an X server instance.
192 *
193 * Fails if no X server is running. Updates the display object.
194- * Reimplemented from ::testing::Test, should only be called by subclasses.
195- * See Google %Test documentation for details.
196+ * Reimplemented from ::testing::Test. See Google %Test documentation for
197+ * details.
198 *
199 * @post Subsequent calls to Display() return a valid pointer or NULL if an error occured.
200 *
201@@ -65,15 +66,13 @@
202 /**
203 * Closes the display.
204 *
205- * Reimplemented from ::testing::Test, should only be called by subclasses.
206- * See Google %Test documentation for details.
207+ * Reimplemented from ::testing::Test. See Google %Test documentation for
208+ * details.
209 *
210 * @post Subsequent calls to Display() return NULL.
211 */
212 virtual void TearDown();
213
214- protected:
215-
216 /**
217 * Accesses the display representing an Xlib connection.
218 *
219
220=== modified file 'm4/gtest.m4'
221--- m4/gtest.m4 2011-12-14 18:29:22 +0000
222+++ m4/gtest.m4 2011-12-14 19:43:29 +0000
223@@ -8,17 +8,16 @@
224 AC_ARG_WITH([gtest-include-path],
225 [AS_HELP_STRING([--with-gtest-include-path],
226 [location of the Google test headers, defaults to /usr/include])],
227- [GTEST_CXXFLAGS="-I$withval"],
228- [GTEST_CXXFLAGS='-I/usr/include'])
229+ [GTEST_CPPFLAGS="-I$withval"])
230
231 AC_ARG_WITH([gtest-lib-path],
232 [AS_HELP_STRING([--with-gtest-lib-path], [location of the Google test libraries])],
233 [GTEST_LDFLAGS="-L$withval -lpthread"],
234- [GTEST_LDFLAGS='-lgtest -lpthread'])
235+ [GTEST_LDFLAGS='-lpthread'])
236
237 AC_LANG_PUSH(C++)
238
239- AC_CHECK_LIB([gtest], [main], [:], [:], [-lpthread])
240+ AC_CHECK_LIB([gtest], [main], [:], [:], [$GTEST_LDFLAGS])
241
242 AC_LANG_POP
243 ]) # AC_CHECK_GTEST
244
245=== modified file 'src/environment.cpp'
246--- src/environment.cpp 2011-12-14 17:13:34 +0000
247+++ src/environment.cpp 2011-12-14 19:43:29 +0000
248@@ -60,7 +60,7 @@
249 d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(),
250 display_string, "-config", d_->path_to_conf.c_str(), NULL);
251
252- setenv("DISPLAY", display_string, true);
253+ Process::SetEnv("DISPLAY", display_string, true);
254
255 for (int i = 0; i < 10; ++i) {
256 Display* display = XOpenDisplay(NULL);
257
258=== modified file 'src/process.cpp'
259--- src/process.cpp 2011-12-14 17:13:34 +0000
260+++ src/process.cpp 2011-12-14 19:43:29 +0000
261@@ -115,7 +115,7 @@
262 }
263
264 std::string xorg::testing::Process::GetEnv(const std::string& name,
265- bool* exists) const {
266+ bool* exists) {
267 const char* var = getenv(name.c_str());
268 if (exists != NULL)
269 *exists = (var != NULL);

Subscribers

People subscribed via source and target branches