зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475256 - Refactor CodeCoverageMixin to pass --java-coverage-output-dir instead of a file path. r=gbrown,marco
Differential Revision: https://phabricator.services.mozilla.com/D4142 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0f87b879ff
Коммит
48c6ba440f
|
@ -52,10 +52,14 @@ class JUnitTestRunner(MochitestDesktop):
|
||||||
update_mozinfo()
|
update_mozinfo()
|
||||||
self.remote_profile = posixpath.join(self.device.test_root, 'junit-profile')
|
self.remote_profile = posixpath.join(self.device.test_root, 'junit-profile')
|
||||||
|
|
||||||
if self.options.coverage and not self.options.coverage_output_path:
|
if self.options.coverage and not self.options.coverage_output_dir:
|
||||||
raise Exception("--coverage-output-path is required when using --enable-coverage")
|
raise Exception("--coverage-output-dir is required when using --enable-coverage")
|
||||||
self.remote_coverage_output_path = posixpath.join(self.device.test_root,
|
if self.options.coverage:
|
||||||
'junit-coverage.ec')
|
self.remote_coverage_output_file = posixpath.join(self.device.test_root,
|
||||||
|
'junit-coverage.ec')
|
||||||
|
self.coverage_output_file = os.path.join(self.options.coverage_output_dir,
|
||||||
|
'junit-coverage.ec')
|
||||||
|
|
||||||
self.server_init()
|
self.server_init()
|
||||||
|
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
@ -153,7 +157,7 @@ class JUnitTestRunner(MochitestDesktop):
|
||||||
# enable code coverage reports
|
# enable code coverage reports
|
||||||
if self.options.coverage:
|
if self.options.coverage:
|
||||||
cmd = cmd + " -e coverage true"
|
cmd = cmd + " -e coverage true"
|
||||||
cmd = cmd + " -e coverageFile %s" % self.remote_coverage_output_path
|
cmd = cmd + " -e coverageFile %s" % self.remote_coverage_output_file
|
||||||
# environment
|
# environment
|
||||||
env = {}
|
env = {}
|
||||||
env["MOZ_CRASHREPORTER"] = "1"
|
env["MOZ_CRASHREPORTER"] = "1"
|
||||||
|
@ -273,12 +277,12 @@ class JUnitTestRunner(MochitestDesktop):
|
||||||
|
|
||||||
if self.options.coverage:
|
if self.options.coverage:
|
||||||
try:
|
try:
|
||||||
self.device.pull(self.remote_coverage_output_path,
|
self.device.pull(self.remote_coverage_output_file,
|
||||||
self.options.coverage_output_path)
|
self.coverage_output_file)
|
||||||
except ADBError:
|
except ADBError:
|
||||||
# Avoid a task retry in case the code coverage file is not found.
|
# Avoid a task retry in case the code coverage file is not found.
|
||||||
self.log.error("No code coverage file (%s) found on remote device" %
|
self.log.error("No code coverage file (%s) found on remote device" %
|
||||||
self.remote_coverage_output_path)
|
self.remote_coverage_output_file)
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
return 1 if self.fail_count else 0
|
return 1 if self.fail_count else 0
|
||||||
|
@ -388,12 +392,12 @@ class JunitArgumentParser(argparse.ArgumentParser):
|
||||||
dest="coverage",
|
dest="coverage",
|
||||||
default=False,
|
default=False,
|
||||||
help="Enable code coverage collection.")
|
help="Enable code coverage collection.")
|
||||||
self.add_argument("--coverage-output-path",
|
self.add_argument("--coverage-output-dir",
|
||||||
action="store",
|
action="store",
|
||||||
type=str,
|
type=str,
|
||||||
dest="coverage_output_path",
|
dest="coverage_output_dir",
|
||||||
default=None,
|
default=None,
|
||||||
help="If collecting code coverage, save the report file to this path.")
|
help="If collecting code coverage, save the report file in this dir.")
|
||||||
# Additional options for server.
|
# Additional options for server.
|
||||||
self.add_argument("--certificate-path",
|
self.add_argument("--certificate-path",
|
||||||
action="store",
|
action="store",
|
||||||
|
|
|
@ -140,8 +140,7 @@ class CodeCoverageMixin(SingleTestMixin):
|
||||||
os.remove(classfiles_zip_path)
|
os.remove(classfiles_zip_path)
|
||||||
|
|
||||||
# Create the directory where the emulator coverage file will be placed.
|
# Create the directory where the emulator coverage file will be placed.
|
||||||
self.java_coverage_output_path = os.path.join(tempfile.mkdtemp(),
|
self.java_coverage_output_dir = tempfile.mkdtemp()
|
||||||
'junit-coverage.ec')
|
|
||||||
|
|
||||||
@PostScriptAction('download-and-extract')
|
@PostScriptAction('download-and-extract')
|
||||||
def setup_coverage_tools(self, action, success=None):
|
def setup_coverage_tools(self, action, success=None):
|
||||||
|
@ -503,18 +502,22 @@ class CodeCoverageMixin(SingleTestMixin):
|
||||||
return
|
return
|
||||||
|
|
||||||
# If the emulator became unresponsive, the task has failed and we don't
|
# If the emulator became unresponsive, the task has failed and we don't
|
||||||
# have the coverage report file, so stop running this function and
|
# have any coverage report file, so stop running this function and
|
||||||
# allow the task to be retried automatically.
|
# allow the task to be retried automatically.
|
||||||
if not success and not os.path.exists(self.java_coverage_output_path):
|
if not success and not os.listdir(self.java_coverage_output_dir):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
report_files = [os.path.join(self.java_coverage_output_dir, f)
|
||||||
|
for f in os.listdir(self.java_coverage_output_dir)]
|
||||||
|
assert len(report_files) > 0, "JaCoCo coverage data files were not found."
|
||||||
|
|
||||||
dirs = self.query_abs_dirs()
|
dirs = self.query_abs_dirs()
|
||||||
xml_path = tempfile.mkdtemp()
|
xml_path = tempfile.mkdtemp()
|
||||||
jacoco_command = ['java', '-jar', self.jacoco_jar, 'report',
|
jacoco_command = ['java', '-jar', self.jacoco_jar, 'report'] + \
|
||||||
self.java_coverage_output_path,
|
report_files + \
|
||||||
'--classfiles', self.classfiles_dir,
|
['--classfiles', self.classfiles_dir,
|
||||||
'--name', 'geckoview-junit',
|
'--name', 'geckoview-junit',
|
||||||
'--xml', os.path.join(xml_path, 'geckoview-junit.xml')]
|
'--xml', os.path.join(xml_path, 'geckoview-junit.xml')]
|
||||||
self.run_command(jacoco_command, halt_on_failure=True)
|
self.run_command(jacoco_command, halt_on_failure=True)
|
||||||
|
|
||||||
grcov_command = [
|
grcov_command = [
|
||||||
|
|
|
@ -493,7 +493,7 @@ class AndroidEmulatorTest(TestingMixin, BaseScript, MozbaseMixin, CodeCoverageMi
|
||||||
|
|
||||||
if self.java_code_coverage_enabled:
|
if self.java_code_coverage_enabled:
|
||||||
cmd.extend(['--enable-coverage',
|
cmd.extend(['--enable-coverage',
|
||||||
'--coverage-output-path', self.java_coverage_output_path])
|
'--coverage-output-dir', self.java_coverage_output_dir])
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче