Implement listing tests to a JSON file for iOS gtest test launcher
[chromium-blink-merge.git] / base / test / launcher / unit_test_launcher_ios.cc
blobd4276c89bccf0e1e8c4de3898f9ffc73807d68fe
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
3 // found in the LICENSE file.
5 #include "base/test/launcher/unit_test_launcher.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/logging.h"
10 #include "base/test/gtest_util.h"
11 #include "base/test/test_switches.h"
13 namespace base {
15 int LaunchUnitTests(int argc,
16 char** argv,
17 const RunTestSuiteCallback& run_test_suite) {
18 CHECK(CommandLine::InitializedForCurrentProcess() ||
19 CommandLine::Init(argc, argv));
20 const CommandLine* command_line = CommandLine::ForCurrentProcess();
21 if (command_line->HasSwitch(switches::kTestLauncherListTests)) {
22 FilePath list_path(command_line->GetSwitchValuePath(
23 switches::kTestLauncherListTests));
24 if (WriteCompiledInTestsToFile(list_path)) {
25 return 0;
26 } else {
27 LOG(ERROR) << "Failed to write list of tests.";
28 return 1;
32 return run_test_suite.Run();
35 } // namespace base