OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generates incremental code coverage reports for Java code in Chromium. | 6 """Generates incremental code coverage reports for Java code in Chromium. |
7 | 7 |
8 Usage: | 8 Usage: |
9 | 9 |
10 build/android/emma_coverage_stats.py -v --out <output file path> --emma-dir | 10 build/android/emma_coverage_stats.py -v --out <output file path> --emma-dir |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 package_emma_file_path, self._XPATH_SELECT_CLASS_ELEMENTS) | 189 package_emma_file_path, self._XPATH_SELECT_CLASS_ELEMENTS) |
190 | 190 |
191 for class_name_element in coverage_file_link_elements: | 191 for class_name_element in coverage_file_link_elements: |
192 emma_coverage_file_path = os.path.join( | 192 emma_coverage_file_path = os.path.join( |
193 self._emma_files_path, class_name_element.attrib['HREF']) | 193 self._emma_files_path, class_name_element.attrib['HREF']) |
194 full_package_name = '%s.%s' % (package_name, class_name_element.text) | 194 full_package_name = '%s.%s' % (package_name, class_name_element.text) |
195 package_to_emma[full_package_name] = emma_coverage_file_path | 195 package_to_emma[full_package_name] = emma_coverage_file_path |
196 | 196 |
197 return package_to_emma | 197 return package_to_emma |
198 | 198 |
| 199 # pylint: disable=no-self-use |
199 def _FindElements(self, file_path, xpath_selector): | 200 def _FindElements(self, file_path, xpath_selector): |
200 """Reads a HTML file and performs an XPath match. | 201 """Reads a HTML file and performs an XPath match. |
201 | 202 |
202 Args: | 203 Args: |
203 file_path: String representing the path to the HTML file. | 204 file_path: String representing the path to the HTML file. |
204 xpath_selector: String representing xpath search pattern. | 205 xpath_selector: String representing xpath search pattern. |
205 | 206 |
206 Returns: | 207 Returns: |
207 A list of ElementTree.Elements matching the given XPath selector. | 208 A list of ElementTree.Elements matching the given XPath selector. |
208 Returns an empty list if there is no match. | 209 Returns an empty list if there is no match. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 'total': total_lines | 316 'total': total_lines |
316 }, | 317 }, |
317 'incremental': { | 318 'incremental': { |
318 'covered': incremental_covered_lines, | 319 'covered': incremental_covered_lines, |
319 'total': incremental_total_lines | 320 'total': incremental_total_lines |
320 }, | 321 }, |
321 'source': line_by_line_coverage, | 322 'source': line_by_line_coverage, |
322 } | 323 } |
323 return file_coverage_stats | 324 return file_coverage_stats |
324 | 325 |
| 326 # pylint: disable=no-self-use |
325 def GetSummaryStatsForLines(self, line_coverage): | 327 def GetSummaryStatsForLines(self, line_coverage): |
326 """Gets summary stats for a given list of LineCoverage objects. | 328 """Gets summary stats for a given list of LineCoverage objects. |
327 | 329 |
328 Args: | 330 Args: |
329 line_coverage: A list of LineCoverage objects. | 331 line_coverage: A list of LineCoverage objects. |
330 | 332 |
331 Returns: | 333 Returns: |
332 A tuple containing the number of lines that are covered and the total | 334 A tuple containing the number of lines that are covered and the total |
333 number of lines that are executable, respectively | 335 number of lines that are executable, respectively |
334 """ | 336 """ |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 'code for which coverage information is desired.') | 468 'code for which coverage information is desired.') |
467 argparser.add_argument('-v', '--verbose', action='count', | 469 argparser.add_argument('-v', '--verbose', action='count', |
468 help='Print verbose log information.') | 470 help='Print verbose log information.') |
469 args = argparser.parse_args() | 471 args = argparser.parse_args() |
470 run_tests_helper.SetLogLevel(args.verbose) | 472 run_tests_helper.SetLogLevel(args.verbose) |
471 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) | 473 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) |
472 | 474 |
473 | 475 |
474 if __name__ == '__main__': | 476 if __name__ == '__main__': |
475 sys.exit(main()) | 477 sys.exit(main()) |
OLD | NEW |