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
=== modified file 'tests/include/mir_test_framework/command_line_server_configuration.h'
--- tests/include/mir_test_framework/command_line_server_configuration.h 2014-05-16 15:46:58 +0000
+++ tests/include/mir_test_framework/command_line_server_configuration.h 2014-11-21 11:03:26 +0000
@@ -27,12 +27,15 @@
27{27{
28class DefaultConfiguration;28class DefaultConfiguration;
29}29}
30class Server;
30}31}
3132
32namespace mir_test_framework33namespace mir_test_framework
33{34{
34 auto configuration_from_commandline() 35 auto configuration_from_commandline()
35 -> std::shared_ptr<mir::options::DefaultConfiguration>;36 -> std::shared_ptr<mir::options::DefaultConfiguration>;
37
38 void configure_from_commandline(mir::Server& server);
36}39}
3740
38#endif /* MIR_TEST_FRAMEWORK_COMMAND_LINE_SERVER_CONFIGURATION */41#endif /* MIR_TEST_FRAMEWORK_COMMAND_LINE_SERVER_CONFIGURATION */
3942
=== modified file 'tests/mir_test_framework/command_line_server_configuration.cpp'
--- tests/mir_test_framework/command_line_server_configuration.cpp 2014-05-16 15:46:58 +0000
+++ tests/mir_test_framework/command_line_server_configuration.cpp 2014-11-21 11:03:26 +0000
@@ -17,6 +17,7 @@
1717
18#include "mir_test_framework/command_line_server_configuration.h"18#include "mir_test_framework/command_line_server_configuration.h"
19#include "mir/options/default_configuration.h"19#include "mir/options/default_configuration.h"
20#include "mir/server.h"
2021
21#include <gtest/gtest.h>22#include <gtest/gtest.h>
2223
@@ -31,26 +32,25 @@
31char const** argv;32char const** argv;
32}33}
3334
34namespace mir_test_framework35auto mir_test_framework::configuration_from_commandline()
35{36-> std::shared_ptr<mo::DefaultConfiguration>
36 auto configuration_from_commandline()37{
37 -> std::shared_ptr<mo::DefaultConfiguration>38 return std::make_shared<mo::DefaultConfiguration>(::argc, ::argv);
38 {39}
39 return std::make_shared<mo::DefaultConfiguration>(::argc, ::argv);40
40 }41void mir_test_framework::configure_from_commandline(mir::Server& server)
42{
43 server.set_command_line(::argc, ::argv);
41}44}
4245
43int main(int argc, char** argv)46int main(int argc, char** argv)
44{47{
45 // Override this standard gtest message48 // Override this standard gtest message
46 std::cout << "Running main() from " << basename(__FILE__) << std::endl;49 std::cout << "Running main() from " << basename(__FILE__) << std::endl;
47 ::argc = std::remove_if(50 ::testing::InitGoogleTest(&argc, argv);
48 argv,51
49 argv+argc,
50 [](char const* arg) { return !strncmp(arg, "--gtest_", 8); }) - argv;
51 ::argv = const_cast<char const**>(argv);52 ::argv = const_cast<char const**>(argv);
5253 ::argc = argc;
53 ::testing::InitGoogleTest(&argc, argv);
5454
55 return RUN_ALL_TESTS();55 return RUN_ALL_TESTS();
56}56}
5757
=== modified file 'tests/mir_test_framework/headless_test.cpp'
--- tests/mir_test_framework/headless_test.cpp 2014-11-06 03:56:24 +0000
+++ tests/mir_test_framework/headless_test.cpp 2014-11-21 11:03:26 +0000
@@ -17,9 +17,11 @@
17 */17 */
1818
19#include "mir_test_framework/headless_test.h"19#include "mir_test_framework/headless_test.h"
20#include "mir_test_framework/command_line_server_configuration.h"
2021
21#include "mir/fd.h"22#include "mir/fd.h"
22#include "mir/main_loop.h"23#include "mir/main_loop.h"
24#include "mir/options/option.h"
2325
24#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
2527
@@ -32,6 +34,7 @@
3234
33mtf::HeadlessTest::HeadlessTest()35mtf::HeadlessTest::HeadlessTest()
34{36{
37 configure_from_commandline(server);
35 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");38 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");
36}39}
3740

Subscribers

People subscribed via source and target branches