diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-08-09 16:43:25 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-10 17:40:32 +0000 |
commit | d9b0dac5e78795fa916c163fac385182fc9ceea9 (patch) | |
tree | 16518f182f03f32829b1c32aa7f7143b2fc7bff3 /testing/tools/coverage | |
parent | 7e805d1a6f3bf7ddd04b2c1ce857a2cf6d9ff873 (diff) | |
download | pdfium-d9b0dac5e78795fa916c163fac385182fc9ceea9.tar.xz |
Extracting GetBooleanGnArg from coverage_report.py
Change-Id: I5475b37aad69361e2e7fae4ce69faf011e3b5c40
Reviewed-on: https://pdfium-review.googlesource.com/10030
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'testing/tools/coverage')
-rwxr-xr-x | testing/tools/coverage/coverage_report.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/testing/tools/coverage/coverage_report.py b/testing/tools/coverage/coverage_report.py index a4222558e4..c12e6cd6c8 100755 --- a/testing/tools/coverage/coverage_report.py +++ b/testing/tools/coverage/coverage_report.py @@ -12,13 +12,25 @@ Requires that 'use_coverage = true' is set in args.gn. import argparse from collections import namedtuple -import pprint import os +import pprint import re import subprocess import sys +# Add src dir to path to avoid having to set PYTHONPATH. +sys.path.append( + os.path.abspath( + os.path.join( + os.path.dirname(__file__), + os.path.pardir, + os.path.pardir, + os.path.pardir))) + +from testing.tools.common import GetBooleanGnArg + + # 'binary' is the file that is to be run for the test. # 'use_test_runner' indicates if 'binary' depends on test_runner.py and thus # requires special handling. @@ -77,12 +89,13 @@ class CoverageExecutor(object): 'No valid tests in set to be run. This is likely due to bad command ' 'line arguments') - if not self.boolean_gn_arg('use_coverage'): + if not GetBooleanGnArg('use_coverage', self.build_directory, self.verbose): parser.error( 'use_coverage does not appear to be set to true for build, but is ' 'needed') - self.use_goma = self.boolean_gn_arg('use_goma') + self.use_goma = GetBooleanGnArg('use_goma', self.build_directory, + self.verbose) self.output_directory = args['output_directory'] if not os.path.exists(self.output_directory): @@ -93,18 +106,6 @@ class CoverageExecutor(object): self.coverage_totals_path = os.path.join(self.output_directory, 'pdfium_totals.info') - def boolean_gn_arg(self, arg): - """Extract the value of a boolean flag in args.gn""" - cwd = os.getcwd() - os.chdir(self.build_directory) - gn_args_output = self.check_output( - ['gn', 'args', '.', '--list=%s' % arg, '--short']) - os.chdir(cwd) - arg_match_output = re.match('%s = (.*)' % arg, gn_args_output).group(1) - if self.verbose: - print "Found '%s' for value of %s" % (arg_match_output, arg) - return arg_match_output == 'true' - def check_output(self, args, dry_run=False, env=None): """Dry run aware wrapper of subprocess.check_output()""" if dry_run: |