| 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 |
| 11 <EMMA file directory> --lines-for-coverage-file | 11 <EMMA file directory> --lines-for-coverage-file |
| 12 <path to file containing lines for coverage> | 12 <path to file containing lines for coverage> |
| 13 | 13 |
| 14 Creates a JSON representation of the overall and file coverage stats and saves | 14 Creates a JSON representation of the overall and file coverage stats and saves |
| 15 this information to the specified output file. | 15 this information to the specified output file. |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 import argparse | 18 import argparse |
| 19 import collections | 19 import collections |
| 20 import json | 20 import json |
| 21 import logging | 21 import logging |
| 22 import os | 22 import os |
| 23 import re | 23 import re |
| 24 import sys | 24 import sys |
| 25 from xml.etree import ElementTree | 25 from xml.etree import ElementTree |
| 26 | 26 |
| 27 from pylib.utils import run_tests_helper | 27 from devil.utils import run_tests_helper |
| 28 | 28 |
| 29 NOT_EXECUTABLE = -1 | 29 NOT_EXECUTABLE = -1 |
| 30 NOT_COVERED = 0 | 30 NOT_COVERED = 0 |
| 31 COVERED = 1 | 31 COVERED = 1 |
| 32 PARTIALLY_COVERED = 2 | 32 PARTIALLY_COVERED = 2 |
| 33 | 33 |
| 34 # Coverage information about a single line of code. | 34 # Coverage information about a single line of code. |
| 35 LineCoverage = collections.namedtuple( | 35 LineCoverage = collections.namedtuple( |
| 36 'LineCoverage', | 36 'LineCoverage', |
| 37 ['lineno', 'source', 'covered_status', 'fractional_line_coverage']) | 37 ['lineno', 'source', 'covered_status', 'fractional_line_coverage']) |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 'code for which coverage information is desired.') | 466 'code for which coverage information is desired.') |
| 467 argparser.add_argument('-v', '--verbose', action='count', | 467 argparser.add_argument('-v', '--verbose', action='count', |
| 468 help='Print verbose log information.') | 468 help='Print verbose log information.') |
| 469 args = argparser.parse_args() | 469 args = argparser.parse_args() |
| 470 run_tests_helper.SetLogLevel(args.verbose) | 470 run_tests_helper.SetLogLevel(args.verbose) |
| 471 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) | 471 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) |
| 472 | 472 |
| 473 | 473 |
| 474 if __name__ == '__main__': | 474 if __name__ == '__main__': |
| 475 sys.exit(main()) | 475 sys.exit(main()) |
| OLD | NEW |