Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: build/android/emma_coverage_stats.py

Issue 1290593002: Changed behavior when no files require coverage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/coverage.py -v --out <output file path> --emma-dir 10 build/android/coverage.py -v --out <output file path> --emma-dir
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 that we should compute coverage information on lines 1 - 3 for file1. 443 that we should compute coverage information on lines 1 - 3 for file1.
444 out_file_path: A string representing the location to write the JSON report. 444 out_file_path: A string representing the location to write the JSON report.
445 coverage_dir: A string representing the file path where the EMMA 445 coverage_dir: A string representing the file path where the EMMA
446 HTML coverage files are located (i.e. folder where index.html is located). 446 HTML coverage files are located (i.e. folder where index.html is located).
447 """ 447 """
448 with open(line_coverage_file) as f: 448 with open(line_coverage_file) as f:
449 potential_files_for_coverage = json.load(f) 449 potential_files_for_coverage = json.load(f)
450 files_for_coverage = {f: lines 450 files_for_coverage = {f: lines
451 for f, lines in potential_files_for_coverage.iteritems() 451 for f, lines in potential_files_for_coverage.iteritems()
452 if _EmmaCoverageStats.NeedsCoverage(f)} 452 if _EmmaCoverageStats.NeedsCoverage(f)}
453 if not files_for_coverage:
454 logging.info('No Java files requiring coverage were included in %s.',
455 line_coverage_file)
456 return
457 453
458 code_coverage = _EmmaCoverageStats(coverage_dir, files_for_coverage.keys()) 454 coverage_results = {}
459 coverage_results = code_coverage.GetCoverageDict( 455 if files_for_coverage:
460 files_for_coverage) 456 code_coverage = _EmmaCoverageStats(coverage_dir, files_for_coverage.keys())
457 coverage_results = code_coverage.GetCoverageDict(
458 files_for_coverage)
461 459
mikecase (-- gone --) 2015/08/11 23:43:55 nit: Add back the logging statement you removed in
estevenson1 2015/08/11 23:48:16 Done.
462 with open(out_file_path, 'w+') as out_status_file: 460 with open(out_file_path, 'w+') as out_status_file:
463 json.dump(coverage_results, out_status_file) 461 json.dump(coverage_results, out_status_file)
464 462
465 463
466 def main(): 464 def main():
467 argparser = argparse.ArgumentParser() 465 argparser = argparse.ArgumentParser()
468 argparser.add_argument('--out', required=True, type=str, 466 argparser.add_argument('--out', required=True, type=str,
469 help='Report output file path.') 467 help='Report output file path.')
470 argparser.add_argument('--emma-dir', required=True, type=str, 468 argparser.add_argument('--emma-dir', required=True, type=str,
471 help='EMMA HTML report directory.') 469 help='EMMA HTML report directory.')
472 argparser.add_argument('--lines-for-coverage-file', required=True, type=str, 470 argparser.add_argument('--lines-for-coverage-file', required=True, type=str,
473 help='File containing a JSON object. Should contain a ' 471 help='File containing a JSON object. Should contain a '
474 'dict mapping file names to lists of line numbers of ' 472 'dict mapping file names to lists of line numbers of '
475 'code for which coverage information is desired.') 473 'code for which coverage information is desired.')
476 argparser.add_argument('-v', '--verbose', action='count', 474 argparser.add_argument('-v', '--verbose', action='count',
477 help='Print verbose log information.') 475 help='Print verbose log information.')
478 args = argparser.parse_args() 476 args = argparser.parse_args()
479 run_tests_helper.SetLogLevel(args.verbose) 477 run_tests_helper.SetLogLevel(args.verbose)
480 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir) 478 GenerateCoverageReport(args.lines_for_coverage_file, args.out, args.emma_dir)
481 479
482 480
483 if __name__ == '__main__': 481 if __name__ == '__main__':
484 sys.exit(main()) 482 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698