Bug 1475256 - Turn archive-geckoview-coverage-artifacts into archive-coverage-artifacts. r=nalexander

Rename the command and extend it to also archive Fennec class files into
another artifact, target.app_classfiles.zip.

Depends on D4142

Differential Revision: https://phabricator.services.mozilla.com/D4143

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tudor-Gabriel Vîjială 2018-09-06 17:00:17 +00:00
parent 48c6ba440f
commit 0f2ee78ad6
7 changed files with 44 additions and 13 deletions

View File

@ -528,3 +528,30 @@ apply from: "${topsrcdir}/mobile/android/gradle/jacoco_dependencies.gradle"
if (project.hasProperty('enable_code_coverage')) {
apply from: "${topsrcdir}/mobile/android/gradle/jacoco_for_junit.gradle"
}
// Set up code coverage for tests on emulators.
if (mozconfig.substs.MOZ_JAVA_CODE_COVERAGE) {
// Generate tasks to archive compiled classfiles for later use with JaCoCo report generation.
// One of these tasks is used by `mach android archive-coverage-artifacts`.
android.applicationVariants.all { variant ->
def name = variant.name
def compileTask = tasks.getByName("compile${name.capitalize()}JavaWithJavac")
task "archiveClassfiles${name.capitalize()}"(type: Zip, dependsOn: compileTask) {
description = "Archive compiled classfiles for $name in order to export them as code coverage artifacts."
def fileFilter = ['**/androidTest/**',
'**/test/**',
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*']
from fileTree(dir: compileTask.destinationDir, excludes: fileFilter)
destinationDir = file("${buildDir}/coverage")
// Note: This task assumes only one variant of archiveClassfiles* will be used.
// Running multiple variants of this task will overwrite the output archive.
archiveName = 'target.app_classfiles.zip'
}
}
}

View File

@ -101,7 +101,7 @@ To generate the coverage report, we need three things:
classfiles and the coverage counters as input and generates XML reports as
output.
The ``mach android archive-geckoview-coverage-artifacts`` command archives the
The ``mach android archive-coverage-artifacts`` command archives the
class files and exports the ``jacoco-cli`` jar file after the build is done.
These files are later saved as public artifacts of the build.

View File

@ -428,7 +428,7 @@ if (mozconfig.substs.MOZ_JAVA_CODE_COVERAGE) {
}
}
// This task is used by `mach android archive-geckoview-coverage-artifacts`.
// This task is used by `mach android archive-coverage-artifacts`.
task copyCoverageDependencies(type: Copy) {
from(configurations.coverageDependency) {
include 'org.jacoco.cli-*-nodeps.jar'
@ -438,7 +438,7 @@ if (mozconfig.substs.MOZ_JAVA_CODE_COVERAGE) {
}
// Generate tasks to archive compiled classfiles for later use with JaCoCo report generation.
// One of these tasks is used by `mach android archive-geckoview-coverage-artifacts`.
// One of these tasks is used by `mach android archive-coverage-artifacts`.
android.libraryVariants.all { variant ->
def name = variant.name
def compileTask = tasks.getByName("compile${name.capitalize()}JavaWithJavac")

View File

@ -238,15 +238,16 @@ set_config('GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS', gradle_android_archive_geck
@depends(gradle_android_build_config)
def gradle_android_archive_geckoview_coverage_artifacts_tasks(build_config):
'''Gradle tasks run by |mach android archive-geckoview-coverage-artifacts|.'''
def gradle_android_archive_coverage_artifacts_tasks(build_config):
'''Gradle tasks run by |mach android archive-coverage-artifacts|.'''
return [
'geckoview:archiveClassfiles{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
'geckoview:copyCoverageDependencies',
'app:archiveClassfiles{app.variant.name}'.format(app=build_config.app),
]
set_config('GRADLE_ANDROID_ARCHIVE_GECKOVIEW_COVERAGE_ARTIFACTS_TASKS',
gradle_android_archive_geckoview_coverage_artifacts_tasks)
set_config('GRADLE_ANDROID_ARCHIVE_COVERAGE_ARTIFACTS_TASKS',
gradle_android_archive_coverage_artifacts_tasks)
@depends(
@ -259,7 +260,7 @@ set_config('GRADLE_ANDROID_ARCHIVE_GECKOVIEW_COVERAGE_ARTIFACTS_TASKS',
gradle_android_generate_sdk_bindings_tasks,
gradle_android_generate_generated_jni_wrappers_tasks,
gradle_android_generate_fennec_jni_wrappers_tasks,
gradle_android_archive_geckoview_coverage_artifacts_tasks,
gradle_android_archive_coverage_artifacts_tasks,
)
@imports(_from='itertools', _import='imap')
@imports(_from='itertools', _import='chain')

View File

@ -415,12 +415,12 @@ class MachCommands(MachCommandBase):
return 0
@SubCommand('android', 'archive-geckoview-coverage-artifacts',
"""Archive compiled geckoview classfiles to be used later in generating code
@SubCommand('android', 'archive-coverage-artifacts',
"""Archive compiled classfiles to be used later in generating code
coverage reports. See https://firefox-source-docs.mozilla.org/mobile/android/fennec/testcoverage.html""") # NOQA: E501
@CommandArgument('args', nargs=argparse.REMAINDER)
def android_archive_geckoview_classfiles(self, args):
self.gradle(self.substs['GRADLE_ANDROID_ARCHIVE_GECKOVIEW_COVERAGE_ARTIFACTS_TASKS'] +
def android_archive_classfiles(self, args):
self.gradle(self.substs['GRADLE_ANDROID_ARCHIVE_COVERAGE_ARTIFACTS_TASKS'] +
["--continue"] + args, verbose=True)
return 0

View File

@ -86,6 +86,9 @@ android-api-16-ccov/debug:
- name: public/build/target.geckoview_classfiles.zip
path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/geckoview/coverage/target.geckoview_classfiles.zip
type: file
- name: public/build/target.app_classfiles.zip
path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/coverage/target.app_classfiles.zip
type: file
- name: public/build/target.jacoco-cli.jar
path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/geckoview/coverage/target.jacoco-cli.jar
type: file

View File

@ -9,7 +9,7 @@ config = {
'archive-geckoview',
],
['android',
'archive-geckoview-coverage-artifacts',
'archive-coverage-artifacts',
],
],
}