| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 std::vector<std::string> new_test_names(test_names); | 152 std::vector<std::string> new_test_names(test_names); |
| 153 std::string test_name(new_test_names.back()); | 153 std::string test_name(new_test_names.back()); |
| 154 new_test_names.pop_back(); | 154 new_test_names.pop_back(); |
| 155 | 155 |
| 156 // Create a dedicated temporary directory to store the xml result data | 156 // Create a dedicated temporary directory to store the xml result data |
| 157 // per run to ensure clean state and make it possible to launch multiple | 157 // per run to ensure clean state and make it possible to launch multiple |
| 158 // processes in parallel. | 158 // processes in parallel. |
| 159 base::FilePath output_file; | 159 base::FilePath output_file; |
| 160 CHECK(file_util::CreateNewTempDirectory(FilePath::StringType(), | 160 CHECK(CreateNewTempDirectory(FilePath::StringType(), &output_file)); |
| 161 &output_file)); | |
| 162 output_file = output_file.AppendASCII("test_results.xml"); | 161 output_file = output_file.AppendASCII("test_results.xml"); |
| 163 | 162 |
| 164 std::vector<std::string> current_test_names; | 163 std::vector<std::string> current_test_names; |
| 165 current_test_names.push_back(test_name); | 164 current_test_names.push_back(test_name); |
| 166 CommandLine cmd_line( | 165 CommandLine cmd_line( |
| 167 GetCommandLineForChildGTestProcess(current_test_names, output_file)); | 166 GetCommandLineForChildGTestProcess(current_test_names, output_file)); |
| 168 | 167 |
| 169 GTestCallbackState callback_state; | 168 GTestCallbackState callback_state; |
| 170 callback_state.test_launcher = test_launcher; | 169 callback_state.test_launcher = test_launcher; |
| 171 callback_state.test_names = current_test_names; | 170 callback_state.test_names = current_test_names; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 185 const std::vector<std::string>& test_names) { | 184 const std::vector<std::string>& test_names) { |
| 186 DCHECK(thread_checker_.CalledOnValidThread()); | 185 DCHECK(thread_checker_.CalledOnValidThread()); |
| 187 | 186 |
| 188 if (test_names.empty()) | 187 if (test_names.empty()) |
| 189 return; | 188 return; |
| 190 | 189 |
| 191 // Create a dedicated temporary directory to store the xml result data | 190 // Create a dedicated temporary directory to store the xml result data |
| 192 // per run to ensure clean state and make it possible to launch multiple | 191 // per run to ensure clean state and make it possible to launch multiple |
| 193 // processes in parallel. | 192 // processes in parallel. |
| 194 base::FilePath output_file; | 193 base::FilePath output_file; |
| 195 CHECK(file_util::CreateNewTempDirectory(FilePath::StringType(), | 194 CHECK(CreateNewTempDirectory(FilePath::StringType(), &output_file)); |
| 196 &output_file)); | |
| 197 output_file = output_file.AppendASCII("test_results.xml"); | 195 output_file = output_file.AppendASCII("test_results.xml"); |
| 198 | 196 |
| 199 CommandLine cmd_line( | 197 CommandLine cmd_line( |
| 200 GetCommandLineForChildGTestProcess(test_names, output_file)); | 198 GetCommandLineForChildGTestProcess(test_names, output_file)); |
| 201 | 199 |
| 202 // Adjust the timeout depending on how many tests we're running | 200 // Adjust the timeout depending on how many tests we're running |
| 203 // (note that e.g. the last batch of tests will be smaller). | 201 // (note that e.g. the last batch of tests will be smaller). |
| 204 // TODO(phajdan.jr): Consider an adaptive timeout, which can change | 202 // TODO(phajdan.jr): Consider an adaptive timeout, which can change |
| 205 // depending on how many tests ran and how many remain. | 203 // depending on how many tests ran and how many remain. |
| 206 // Note: do NOT parse child's stdout to do that, it's known to be | 204 // Note: do NOT parse child's stdout to do that, it's known to be |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 481 |
| 484 fprintf(stdout, | 482 fprintf(stdout, |
| 485 "Tests took %" PRId64 " seconds.\n", | 483 "Tests took %" PRId64 " seconds.\n", |
| 486 (base::TimeTicks::Now() - start_time).InSeconds()); | 484 (base::TimeTicks::Now() - start_time).InSeconds()); |
| 487 fflush(stdout); | 485 fflush(stdout); |
| 488 | 486 |
| 489 return (success ? 0 : 1); | 487 return (success ? 0 : 1); |
| 490 } | 488 } |
| 491 | 489 |
| 492 } // namespace base | 490 } // namespace base |
| OLD | NEW |