Chromium Code Reviews| 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/test_results_tracker.h" | 5 #include "base/test/launcher/test_results_tracker.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/json/string_escape.h" | 13 #include "base/json/string_escape.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string_util.h" | |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/test/launcher/test_launcher.h" | 17 #include "base/test/launcher/test_launcher.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 | 21 |
| 21 // See https://groups.google.com/a/chromium.org/d/msg/chromium-dev/nkdTP7sstSc/u T3FaE_sgkAJ . | 22 // See https://groups.google.com/a/chromium.org/d/msg/chromium-dev/nkdTP7sstSc/u T3FaE_sgkAJ . |
| 22 using ::operator<<; | 23 using ::operator<<; |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 } | 149 } |
| 149 | 150 |
| 150 void TestResultsTracker::OnTestIterationStarting() { | 151 void TestResultsTracker::OnTestIterationStarting() { |
| 151 DCHECK(thread_checker_.CalledOnValidThread()); | 152 DCHECK(thread_checker_.CalledOnValidThread()); |
| 152 | 153 |
| 153 // Start with a fresh state for new iteration. | 154 // Start with a fresh state for new iteration. |
| 154 iteration_++; | 155 iteration_++; |
| 155 per_iteration_data_.push_back(PerIterationData()); | 156 per_iteration_data_.push_back(PerIterationData()); |
| 156 } | 157 } |
| 157 | 158 |
| 159 void TestResultsTracker::AddTest(const std::string& test_name) { | |
| 160 // Record disabled test names without DISABLED_ prefix so that they are easy | |
| 161 // to compare with regular test names, e.g. before or after disabling. | |
| 162 std::string test_name_no_disabled(test_name); | |
| 163 ReplaceSubstringsAfterOffset(&test_name_no_disabled, 0, "DISABLED_", ""); | |
| 164 all_tests_.insert(test_name_no_disabled); | |
| 165 } | |
| 166 | |
| 167 void TestResultsTracker::AddDisabledTest(const std::string& test_name) { | |
| 168 // Record disabled test names without DISABLED_ prefix so that they are easy | |
| 169 // to compare with regular test names, e.g. before or after disabling. | |
| 170 std::string test_name_no_disabled(test_name); | |
| 171 ReplaceSubstringsAfterOffset(&test_name_no_disabled, 0, "DISABLED_", ""); | |
| 172 disabled_tests_.insert(test_name_no_disabled); | |
|
sky
2014/01/06 19:24:15
nit: refactor 170-171 into function above. I'm thi
Paweł Hajdan Jr.
2014/01/07 09:12:27
Done.
| |
| 173 } | |
| 174 | |
| 158 void TestResultsTracker::AddTestResult(const TestResult& result) { | 175 void TestResultsTracker::AddTestResult(const TestResult& result) { |
| 159 DCHECK(thread_checker_.CalledOnValidThread()); | 176 DCHECK(thread_checker_.CalledOnValidThread()); |
| 160 | 177 |
| 161 per_iteration_data_[iteration_].results[ | 178 per_iteration_data_[iteration_].results[ |
| 162 result.full_name].test_results.push_back(result); | 179 result.full_name].test_results.push_back(result); |
| 163 } | 180 } |
| 164 | 181 |
| 165 void TestResultsTracker::PrintSummaryOfCurrentIteration() const { | 182 void TestResultsTracker::PrintSummaryOfCurrentIteration() const { |
| 166 std::map<TestResult::Status, std::set<std::string> > tests_by_status; | 183 std::map<TestResult::Status, std::set<std::string> > tests_by_status; |
| 167 | 184 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 262 |
| 246 ListValue* global_tags = new ListValue; | 263 ListValue* global_tags = new ListValue; |
| 247 summary_root->Set("global_tags", global_tags); | 264 summary_root->Set("global_tags", global_tags); |
| 248 | 265 |
| 249 for (std::set<std::string>::const_iterator i = global_tags_.begin(); | 266 for (std::set<std::string>::const_iterator i = global_tags_.begin(); |
| 250 i != global_tags_.end(); | 267 i != global_tags_.end(); |
| 251 ++i) { | 268 ++i) { |
| 252 global_tags->AppendString(*i); | 269 global_tags->AppendString(*i); |
| 253 } | 270 } |
| 254 | 271 |
| 272 ListValue* all_tests = new ListValue; | |
| 273 summary_root->Set("all_tests", all_tests); | |
| 274 | |
| 275 for (std::set<std::string>::const_iterator i = all_tests_.begin(); | |
| 276 i != all_tests_.end(); | |
| 277 ++i) { | |
| 278 all_tests->AppendString(*i); | |
| 279 } | |
| 280 | |
| 281 ListValue* disabled_tests = new ListValue; | |
| 282 summary_root->Set("disabled_tests", disabled_tests); | |
| 283 | |
| 284 for (std::set<std::string>::const_iterator i = disabled_tests_.begin(); | |
| 285 i != disabled_tests_.end(); | |
| 286 ++i) { | |
| 287 disabled_tests->AppendString(*i); | |
| 288 } | |
| 289 | |
| 255 ListValue* per_iteration_data = new ListValue; | 290 ListValue* per_iteration_data = new ListValue; |
| 256 summary_root->Set("per_iteration_data", per_iteration_data); | 291 summary_root->Set("per_iteration_data", per_iteration_data); |
| 257 | 292 |
| 258 for (int i = 0; i <= iteration_; i++) { | 293 for (int i = 0; i <= iteration_; i++) { |
| 259 DictionaryValue* current_iteration_data = new DictionaryValue; | 294 DictionaryValue* current_iteration_data = new DictionaryValue; |
| 260 per_iteration_data->Append(current_iteration_data); | 295 per_iteration_data->Append(current_iteration_data); |
| 261 | 296 |
| 262 for (PerIterationData::ResultsMap::const_iterator j = | 297 for (PerIterationData::ResultsMap::const_iterator j = |
| 263 per_iteration_data_[i].results.begin(); | 298 per_iteration_data_[i].results.begin(); |
| 264 j != per_iteration_data_[i].results.end(); | 299 j != per_iteration_data_[i].results.end(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 TestResultsTracker::AggregateTestResult::~AggregateTestResult() { | 344 TestResultsTracker::AggregateTestResult::~AggregateTestResult() { |
| 310 } | 345 } |
| 311 | 346 |
| 312 TestResultsTracker::PerIterationData::PerIterationData() { | 347 TestResultsTracker::PerIterationData::PerIterationData() { |
| 313 } | 348 } |
| 314 | 349 |
| 315 TestResultsTracker::PerIterationData::~PerIterationData() { | 350 TestResultsTracker::PerIterationData::~PerIterationData() { |
| 316 } | 351 } |
| 317 | 352 |
| 318 } // namespace base | 353 } // namespace base |
| OLD | NEW |