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 #ifndef BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ | 5 #ifndef BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ |
| 6 #define BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ | 6 #define BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 // Initialize the result tracker. Must be called exactly once before | 36 // Initialize the result tracker. Must be called exactly once before |
| 37 // calling any other methods. Returns true on success. | 37 // calling any other methods. Returns true on success. |
| 38 bool Init(const CommandLine& command_line) WARN_UNUSED_RESULT; | 38 bool Init(const CommandLine& command_line) WARN_UNUSED_RESULT; |
| 39 | 39 |
| 40 // Called when a test iteration is starting. | 40 // Called when a test iteration is starting. |
| 41 void OnTestIterationStarting(); | 41 void OnTestIterationStarting(); |
| 42 | 42 |
| 43 // Adds |test_name| to the set of discovered tests (this includes all tests | 43 // Adds |test_name| to the set of discovered tests (this includes all tests |
| 44 // present in the executable, not necessarily run). | 44 // present in the executable, not necessarily run). |
| 45 void AddTest(const std::string& test_name); | 45 void AddTest(const std::string& test_name, const std::string& file, int line); |
| 46 | 46 |
| 47 // Adds |test_name| to the set of disabled tests. | 47 // Adds |test_name| to the set of disabled tests. |
| 48 void AddDisabledTest(const std::string& test_name); | 48 void AddDisabledTest(const std::string& test_name); |
| 49 | 49 |
| 50 // Adds |result| to the stored test results. | 50 // Adds |result| to the stored test results. |
| 51 void AddTestResult(const TestResult& result); | 51 void AddTestResult(const TestResult& result); |
| 52 | 52 |
| 53 // Prints a summary of current test iteration to stdout. | 53 // Prints a summary of current test iteration to stdout. |
| 54 void PrintSummaryOfCurrentIteration() const; | 54 void PrintSummaryOfCurrentIteration() const; |
| 55 | 55 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 70 | 70 |
| 71 // Returns a test status map (see above) for current test iteration. | 71 // Returns a test status map (see above) for current test iteration. |
| 72 TestStatusMap GetTestStatusMapForCurrentIteration() const; | 72 TestStatusMap GetTestStatusMapForCurrentIteration() const; |
| 73 | 73 |
| 74 // Returns a test status map (see above) for all test iterations. | 74 // Returns a test status map (see above) for all test iterations. |
| 75 TestStatusMap GetTestStatusMapForAllIterations() const; | 75 TestStatusMap GetTestStatusMapForAllIterations() const; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 void GetTestStatusForIteration(int iteration, TestStatusMap* map) const; | 78 void GetTestStatusForIteration(int iteration, TestStatusMap* map) const; |
| 79 | 79 |
| 80 template<typename InputIterator> | |
| 81 void PrintTests(InputIterator first, | |
| 82 InputIterator last, | |
| 83 const std::string& description) const; | |
| 84 | |
| 80 struct AggregateTestResult { | 85 struct AggregateTestResult { |
| 81 AggregateTestResult(); | 86 AggregateTestResult(); |
| 82 ~AggregateTestResult(); | 87 ~AggregateTestResult(); |
| 83 | 88 |
| 84 std::vector<TestResult> test_results; | 89 std::vector<TestResult> test_results; |
| 85 }; | 90 }; |
| 86 | 91 |
| 87 struct PerIterationData { | 92 struct PerIterationData { |
| 88 PerIterationData(); | 93 PerIterationData(); |
| 89 ~PerIterationData(); | 94 ~PerIterationData(); |
| 90 | 95 |
| 91 // Aggregate test results grouped by full test name. | 96 // Aggregate test results grouped by full test name. |
| 92 typedef std::map<std::string, AggregateTestResult> ResultsMap; | 97 typedef std::map<std::string, AggregateTestResult> ResultsMap; |
| 93 ResultsMap results; | 98 ResultsMap results; |
| 94 }; | 99 }; |
| 95 | 100 |
| 101 struct CodeLocation { | |
| 102 CodeLocation(const std::string f, int l) : file(f), line(l) { | |
|
sky
2015/07/28 22:37:07
const std::string&
Paweł Hajdan Jr.
2015/07/29 08:47:07
Done.
| |
| 103 } | |
| 104 | |
| 105 std::string file; | |
| 106 int line; | |
| 107 }; | |
| 108 | |
| 96 ThreadChecker thread_checker_; | 109 ThreadChecker thread_checker_; |
| 97 | 110 |
| 98 // Set of global tags, i.e. strings indicating conditions that apply to | 111 // Set of global tags, i.e. strings indicating conditions that apply to |
| 99 // the entire test run. | 112 // the entire test run. |
| 100 std::set<std::string> global_tags_; | 113 std::set<std::string> global_tags_; |
| 101 | 114 |
| 102 // Set of all test names discovered in the current executable. | 115 // Set of all test names discovered in the current executable. |
| 103 std::set<std::string> all_tests_; | 116 std::set<std::string> all_tests_; |
| 104 | 117 |
| 118 std::map<std::string, CodeLocation> test_locations_; | |
| 119 | |
| 105 // Set of all disabled tests in the current executable. | 120 // Set of all disabled tests in the current executable. |
| 106 std::set<std::string> disabled_tests_; | 121 std::set<std::string> disabled_tests_; |
| 107 | 122 |
| 108 // Store test results for each iteration. | 123 // Store test results for each iteration. |
| 109 std::vector<PerIterationData> per_iteration_data_; | 124 std::vector<PerIterationData> per_iteration_data_; |
| 110 | 125 |
| 111 // Index of current iteration (starting from 0). -1 before the first | 126 // Index of current iteration (starting from 0). -1 before the first |
| 112 // iteration. | 127 // iteration. |
| 113 int iteration_; | 128 int iteration_; |
| 114 | 129 |
| 115 // File handle of output file (can be NULL if no file). | 130 // File handle of output file (can be NULL if no file). |
| 116 FILE* out_; | 131 FILE* out_; |
| 117 | 132 |
| 118 DISALLOW_COPY_AND_ASSIGN(TestResultsTracker); | 133 DISALLOW_COPY_AND_ASSIGN(TestResultsTracker); |
| 119 }; | 134 }; |
| 120 | 135 |
| 121 } // namespace base | 136 } // namespace base |
| 122 | 137 |
| 123 #endif // BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ | 138 #endif // BASE_TEST_LAUNCHER_TEST_RESULTS_TRACKER_H_ |
| OLD | NEW |