OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/launcher/unit_test_launcher.h" | 5 #include "base/test/launcher/unit_test_launcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/foundation_util.h" |
10 #include "base/test/gtest_util.h" | 12 #include "base/test/gtest_util.h" |
11 #include "base/test/test_switches.h" | 13 #include "base/test/test_switches.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 | 16 |
15 int LaunchUnitTests(int argc, | 17 int LaunchUnitTests(int argc, |
16 char** argv, | 18 char** argv, |
17 const RunTestSuiteCallback& run_test_suite) { | 19 const RunTestSuiteCallback& run_test_suite) { |
18 CHECK(CommandLine::InitializedForCurrentProcess() || | 20 CHECK(CommandLine::InitializedForCurrentProcess() || |
19 CommandLine::Init(argc, argv)); | 21 CommandLine::Init(argc, argv)); |
20 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 22 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
21 if (command_line->HasSwitch(switches::kTestLauncherListTests)) { | 23 if (command_line->HasSwitch(switches::kTestLauncherListTests)) { |
22 FilePath list_path(command_line->GetSwitchValuePath( | 24 FilePath list_path(command_line->GetSwitchValuePath( |
23 switches::kTestLauncherListTests)); | 25 switches::kTestLauncherListTests)); |
24 if (WriteCompiledInTestsToFile(list_path)) { | 26 if (WriteCompiledInTestsToFile(list_path)) { |
25 return 0; | 27 return 0; |
26 } else { | 28 } else { |
27 LOG(ERROR) << "Failed to write list of tests."; | 29 LOG(ERROR) << "Failed to write list of tests."; |
28 return 1; | 30 return 1; |
29 } | 31 } |
| 32 } else if (command_line->HasSwitch( |
| 33 switches::kTestLauncherPrintWritablePath)) { |
| 34 fprintf(stdout, "%s", mac::GetUserLibraryPath().value().c_str()); |
| 35 fflush(stdout); |
| 36 return 0; |
30 } | 37 } |
31 | 38 |
32 return run_test_suite.Run(); | 39 return run_test_suite.Run(); |
33 } | 40 } |
34 | 41 |
35 } // namespace base | 42 } // namespace base |
OLD | NEW |