Bug 1476574 - Enable reset/dump for wpt and cleanup harness code for supporting reset/dump now that it is supported by all test suites. r=jmaher

--HG--
extra : source : c1b3950cc12f1642ad60338d2a8701e2b60131ea
extra : intermediate-source : 4ea7997194e9f995bb0b1e434524a0ea5596d758
extra : histedit_source : fffe672f456fd7c503792d2a3e99184c14bfd36c
This commit is contained in:
Marco Castelluccio 2018-07-19 11:56:43 +02:00
Родитель 87fbf2563c
Коммит bd3f040c33
3 изменённых файлов: 31 добавлений и 29 удалений

Просмотреть файл

@ -204,16 +204,20 @@ class CodeCoverageMixin(SingleTestMixin):
def coverage_args(self):
return []
def set_coverage_env(self, env):
def set_coverage_env(self, env, is_baseline_test=False):
# Set the GCOV directory.
gcov_dir = tempfile.mkdtemp()
env['GCOV_PREFIX'] = gcov_dir
self.gcov_dir = tempfile.mkdtemp()
env['GCOV_PREFIX'] = self.gcov_dir
# Set the GCOV directory where counters will be dumped in per-test mode.
# Resetting/dumping is only available on Linux for the time being
# (https://bugzilla.mozilla.org/show_bug.cgi?id=1471576).
if self.per_test_coverage and not is_baseline_test and self._is_linux():
env['GCOV_RESULTS_DIR'] = tempfile.mkdtemp()
# Set JSVM directory.
jsvm_dir = tempfile.mkdtemp()
env['JS_CODE_COVERAGE_OUTPUT_DIR'] = jsvm_dir
return (gcov_dir, jsvm_dir)
self.jsvm_dir = tempfile.mkdtemp()
env['JS_CODE_COVERAGE_OUTPUT_DIR'] = self.jsvm_dir
@PreScriptAction('run-tests')
def _set_gcov_prefix(self, action):
@ -223,7 +227,7 @@ class CodeCoverageMixin(SingleTestMixin):
if self.per_test_coverage:
return
self.gcov_dir, self.jsvm_dir = self.set_coverage_env(os.environ)
self.set_coverage_env(os.environ)
def parse_coverage_artifacts(self,
gcov_dir,
@ -286,9 +290,11 @@ class CodeCoverageMixin(SingleTestMixin):
else:
return grcov_output_file, jsvm_output_file
def add_per_test_coverage_report(self, gcov_dir, jsvm_dir, suite, test):
def add_per_test_coverage_report(self, env, suite, test):
gcov_dir = env['GCOV_RESULTS_DIR'] if 'GCOV_RESULTS_DIR' in env else self.gcov_dir
grcov_file = self.parse_coverage_artifacts(
gcov_dir, jsvm_dir, merge=True, output_format='coveralls',
gcov_dir, self.jsvm_dir, merge=True, output_format='coveralls',
filter_covered=True,
)
@ -300,6 +306,11 @@ class CodeCoverageMixin(SingleTestMixin):
assert test not in self.per_test_reports[suite]
self.per_test_reports[suite][test] = report_file
if 'GCOV_RESULTS_DIR' in env:
# In this case, parse_coverage_artifacts has removed GCOV_RESULTS_DIR
# so we need to remove GCOV_PREFIX.
shutil.rmtree(self.gcov_dir)
def is_covered(self, sf):
# For C/C++ source files, we can consider a file as being uncovered
# when all its source lines are uncovered.

Просмотреть файл

@ -15,7 +15,6 @@ import re
import sys
import copy
import shutil
import tempfile
import glob
import imp
@ -889,28 +888,18 @@ class DesktopUnittest(TestingMixin, MercurialScript, MozbaseMixin,
final_cmd = copy.copy(cmd)
final_cmd.extend(per_test_args)
final_env = copy.copy(env)
if self.per_test_coverage:
gcov_dir, jsvm_dir = self.set_coverage_env(env)
# Per-test reset/dump is only supported on Linux for the time being.
if not is_baseline_test and \
self._is_linux():
env['GCOV_RESULTS_DIR'] = tempfile.mkdtemp()
self.set_coverage_env(final_env)
return_code = self.run_command(final_cmd, cwd=dirs['abs_work_dir'],
output_timeout=cmd_timeout,
output_parser=parser,
env=env)
env=final_env)
if self.per_test_coverage:
self.add_per_test_coverage_report(
env['GCOV_RESULTS_DIR'] if 'GCOV_RESULTS_DIR' in env else gcov_dir,
jsvm_dir,
suite,
per_test_args[-1]
)
if 'GCOV_RESULTS_DIR' in env:
shutil.rmtree(gcov_dir)
del env['GCOV_RESULTS_DIR']
self.add_per_test_coverage_report(final_env, suite, per_test_args[-1])
# mochitest, reftest, and xpcshell suites do not return
# appropriate return codes. Therefore, we must parse the output

Просмотреть файл

@ -377,17 +377,19 @@ class WebPlatformTest(TestingMixin, MercurialScript, CodeCoverageMixin):
cmd = self._query_cmd(test_types)
cmd.extend(per_test_args)
final_env = copy.copy(env)
if self.per_test_coverage:
gcov_dir, jsvm_dir = self.set_coverage_env(env)
self.set_coverage_env(final_env, is_baseline_test)
return_code = self.run_command(cmd,
cwd=dirs['abs_work_dir'],
output_timeout=1000,
output_parser=parser,
env=env)
env=final_env)
if self.per_test_coverage:
self.add_per_test_coverage_report(gcov_dir, jsvm_dir, suite, per_test_args[-1])
self.add_per_test_coverage_report(final_env, suite, per_test_args[-1])
tbpl_status, log_level, summary = parser.evaluate_parser(return_code,
previous_summary=summary)