Mir

Merge lp:~alan-griffiths/mir/fix-command-line-handling into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2090
Proposed branch: lp:~alan-griffiths/mir/fix-command-line-handling
Merge into: lp:mir
Diff against target: 93 lines (+19/-13)
3 files modified
tests/include/mir_test_framework/command_line_server_configuration.h (+3/-0)
tests/mir_test_framework/command_line_server_configuration.cpp (+13/-13)
tests/mir_test_framework/headless_test.cpp (+3/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-command-line-handling
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+242476@code.launchpad.net

Commit message

tests: fix commandline handling in tests

Description of the change

tests: fix command line handling in tests

The replacement main() screwed up Mir options when there are also gtest options. That's fixed.

Also, the new test framework failed to set the command line for the Mir server

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/include/mir_test_framework/command_line_server_configuration.h'
2--- tests/include/mir_test_framework/command_line_server_configuration.h 2014-05-16 15:46:58 +0000
3+++ tests/include/mir_test_framework/command_line_server_configuration.h 2014-11-21 11:03:26 +0000
4@@ -27,12 +27,15 @@
5 {
6 class DefaultConfiguration;
7 }
8+class Server;
9 }
10
11 namespace mir_test_framework
12 {
13 auto configuration_from_commandline()
14 -> std::shared_ptr<mir::options::DefaultConfiguration>;
15+
16+ void configure_from_commandline(mir::Server& server);
17 }
18
19 #endif /* MIR_TEST_FRAMEWORK_COMMAND_LINE_SERVER_CONFIGURATION */
20
21=== modified file 'tests/mir_test_framework/command_line_server_configuration.cpp'
22--- tests/mir_test_framework/command_line_server_configuration.cpp 2014-05-16 15:46:58 +0000
23+++ tests/mir_test_framework/command_line_server_configuration.cpp 2014-11-21 11:03:26 +0000
24@@ -17,6 +17,7 @@
25
26 #include "mir_test_framework/command_line_server_configuration.h"
27 #include "mir/options/default_configuration.h"
28+#include "mir/server.h"
29
30 #include <gtest/gtest.h>
31
32@@ -31,26 +32,25 @@
33 char const** argv;
34 }
35
36-namespace mir_test_framework
37-{
38- auto configuration_from_commandline()
39- -> std::shared_ptr<mo::DefaultConfiguration>
40- {
41- return std::make_shared<mo::DefaultConfiguration>(::argc, ::argv);
42- }
43+auto mir_test_framework::configuration_from_commandline()
44+-> std::shared_ptr<mo::DefaultConfiguration>
45+{
46+ return std::make_shared<mo::DefaultConfiguration>(::argc, ::argv);
47+}
48+
49+void mir_test_framework::configure_from_commandline(mir::Server& server)
50+{
51+ server.set_command_line(::argc, ::argv);
52 }
53
54 int main(int argc, char** argv)
55 {
56 // Override this standard gtest message
57 std::cout << "Running main() from " << basename(__FILE__) << std::endl;
58- ::argc = std::remove_if(
59- argv,
60- argv+argc,
61- [](char const* arg) { return !strncmp(arg, "--gtest_", 8); }) - argv;
62+ ::testing::InitGoogleTest(&argc, argv);
63+
64 ::argv = const_cast<char const**>(argv);
65-
66- ::testing::InitGoogleTest(&argc, argv);
67+ ::argc = argc;
68
69 return RUN_ALL_TESTS();
70 }
71
72=== modified file 'tests/mir_test_framework/headless_test.cpp'
73--- tests/mir_test_framework/headless_test.cpp 2014-11-06 03:56:24 +0000
74+++ tests/mir_test_framework/headless_test.cpp 2014-11-21 11:03:26 +0000
75@@ -17,9 +17,11 @@
76 */
77
78 #include "mir_test_framework/headless_test.h"
79+#include "mir_test_framework/command_line_server_configuration.h"
80
81 #include "mir/fd.h"
82 #include "mir/main_loop.h"
83+#include "mir/options/option.h"
84
85 #include <boost/throw_exception.hpp>
86
87@@ -32,6 +34,7 @@
88
89 mtf::HeadlessTest::HeadlessTest()
90 {
91+ configure_from_commandline(server);
92 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");
93 }
94

Subscribers

People subscribed via source and target branches