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 import devil_chromium |
27 from devil.utils import run_tests_helper | 28 from devil.utils import run_tests_helper |
28 | 29 |
29 NOT_EXECUTABLE = -1 | 30 NOT_EXECUTABLE = -1 |
30 NOT_COVERED = 0 | 31 NOT_COVERED = 0 |
31 COVERED = 1 | 32 COVERED = 1 |
32 PARTIALLY_COVERED = 2 | 33 PARTIALLY_COVERED = 2 |
33 | 34 |
34 # Coverage information about a single line of code. | 35 # Coverage information about a single line of code. |
35 LineCoverage = collections.namedtuple( | 36 LineCoverage = collections.namedtuple( |
36 'LineCoverage', | 37 'LineCoverage', |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 argparser.add_argument('--emma-dir', required=True, type=str, | 464 argparser.add_argument('--emma-dir', required=True, type=str, |
464 help='EMMA HTML report directory.') | 465 help='EMMA HTML report directory.') |
465 argparser.add_argument('--lines-for-coverage-file', required=True, type=str, | 466 argparser.add_argument('--lines-for-coverage-file', required=True, type=str, |
466 help='File containing a JSON object. Should contain a ' | 467 help='File containing a JSON object. Should contain a ' |
467 'dict mapping file names to lists of line numbers of ' | 468 'dict mapping file names to lists of line numbers of ' |
468 'code for which coverage information is desired.') | 469 'code for which coverage information is desired.') |
469 argparser.add_argument('-v', '--verbose', action='count', | 470 argparser.add_argument('-v', '--verbose', action='count', |
470 help='Print verbose log information.') | 471 help='Print verbose log information.') |
471 args = argparser.parse_args() | 472 args = argparser.parse_args() |
472 run_tests_helper.SetLogLevel(args.verbose) | 473 run_tests_helper.SetLogLevel(args.verbose) |
| 474 devil_chromium.Initialize() |
473 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) | 475 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) |
474 | 476 |
475 | 477 |
476 if __name__ == '__main__': | 478 if __name__ == '__main__': |
477 sys.exit(main()) | 479 sys.exit(main()) |
OLD | NEW |