summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/__init__.py0
-rw-r--r--testing/tools/__init__.py0
-rwxr-xr-xtesting/tools/common.py20
-rwxr-xr-xtesting/tools/coverage/coverage_report.py31
4 files changed, 27 insertions, 24 deletions
diff --git a/testing/__init__.py b/testing/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/__init__.py
diff --git a/testing/tools/__init__.py b/testing/tools/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/tools/__init__.py
diff --git a/testing/tools/common.py b/testing/tools/common.py
index c3bc2181f4..737169f8d3 100755
--- a/testing/tools/common.py
+++ b/testing/tools/common.py
@@ -99,12 +99,14 @@ class DirectoryFinder:
return result
-def GetBooleanGnArg(arg_name, build_dir):
- '''Extract the value of a boolean flag in args.gn'''
- cwd = os.getcwd()
- os.chdir(build_dir)
- gn_args_output = subprocess.check_output(
- ['gn', 'args', '.', '--list=%s' % arg_name, '--short'])
- os.chdir(cwd)
- arg_match_output = re.search('%s = (.*)' % arg_name, gn_args_output).group(1)
- return arg_match_output == 'true'
+def GetBooleanGnArg(arg_name, build_dir, verbose=False):
+ '''Extract the value of a boolean flag in args.gn'''
+ cwd = os.getcwd()
+ os.chdir(build_dir)
+ gn_args_output = subprocess.check_output(
+ ['gn', 'args', '.', '--list=%s' % arg_name, '--short'])
+ os.chdir(cwd)
+ arg_match_output = re.search('%s = (.*)' % arg_name, gn_args_output).group(1)
+ if verbose:
+ print >> sys.stderr, "Found '%s' for value of %s" % (arg_match_output, arg)
+ return arg_match_output == 'true'
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: