diff options
author | Maurice Lam <yukl@google.com> | 2017-04-24 17:19:52 -0700 |
---|---|---|
committer | Maurice Lam <yukl@google.com> | 2017-04-26 00:53:15 +0000 |
commit | 8aaf0419f9e0e2a877a09e3021d96ad5aa6df500 (patch) | |
tree | cf0c17783a1568c12685e92be6f97a80d0183cb6 | |
parent | 1a8259d4fb0a29ca334ac8728ef9ac9e4241f056 (diff) | |
download | setupwizard-8aaf0419f9e0e2a877a09e3021d96ad5aa6df500.tar.gz |
Run Robolectric tests on build server
Configure the build server task to run 'test' task, and zip the
result XMLs to host-test-reports for tradefed to pick it up.
Test: out/dist/host-test-reports get generated by TreeHugger
Bug: 37677781
Change-Id: I6162ce0996912b7445ef92c44e48625c4fb4e48f
-rw-r--r-- | library/self.gradle | 26 | ||||
-rwxr-xr-x | tools/build_for_build_server.sh | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/library/self.gradle b/library/self.gradle index fe68744..b7cbd55 100644 --- a/library/self.gradle +++ b/library/self.gradle @@ -62,12 +62,36 @@ android.lintOptions { android.libraryVariants.all { variant -> variant.assemble.dependsOn(tasks.findByName('lint')) } -// Output all test APKs to the distribution folder def distTask = tasks.findByName('dist') if (distTask) { + // Output all test APKs to the distribution folder android.testVariants.all { variant -> // Make the dist task depend on the test variant, so the test APK will be built distTask.dependsOn variant.assemble // TODO: remap the different test variants to different file names } + + // Output the Robolectric test results to host-test-reports/*.zip + afterEvaluate { + android.unitTestVariants.all { variant -> + def task = tasks.findByName('test' + variant.name.capitalize()) + gradle.taskGraph.whenReady { taskGraph -> + task.ignoreFailures = taskGraph.hasTask(distTask) + } + + // Create a zip file of the XML test reports and dist it to host-test-reports. + // The file path and format should match GradleHostBasedTest class in TradeFed. + def junitReport = task.reports.junitXml + if (junitReport.enabled) { + def zipTask = project.tasks.create("zipResultsOf${task.name.capitalize()}", Zip) { + from junitReport.destination + archiveName = task.name + 'Result.zip' + destinationDir = junitReport.destination.parentFile + } + tasks.dist.dependsOn zipTask + zipTask.mustRunAfter task + dist.file zipTask.archivePath.path, "host-test-reports/${zipTask.archiveName}" + } + } + } } diff --git a/tools/build_for_build_server.sh b/tools/build_for_build_server.sh index 14b5a3b..a90ae67 100755 --- a/tools/build_for_build_server.sh +++ b/tools/build_for_build_server.sh @@ -6,4 +6,4 @@ export TARGET_BUILD_DENSITY="alldpi" export TARGET_BUILD_TYPE="release" export TARGET_BUILD_APPS="setup-wizard-lib" -./gradlew +./gradlew buildProjectFull test |