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
98 lines
3.5 KiB
Groovy
98 lines
3.5 KiB
Groovy
/**
|
|
* This self.gradle build file is only run when built in ub-setupwizard-* branches.
|
|
*/
|
|
apply plugin: 'dist'
|
|
apply from: 'standalone-rules.gradle'
|
|
// Add targets for tests
|
|
android.sourceSets {
|
|
androidTest {
|
|
manifest.srcFile 'test/instrumentation/AndroidManifest.xml'
|
|
java.srcDirs = ['test/instrumentation/src']
|
|
res.srcDirs = ['test/instrumentation/res']
|
|
|
|
dependencies {
|
|
androidTestCompile 'com.android.support.test:rules:0.5'
|
|
androidTestCompile 'com.android.support.test:runner:0.5'
|
|
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
|
|
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
|
|
androidTestCompile 'junit:junit:4.+'
|
|
androidTestCompile 'org.mockito:mockito-core:1.9.5'
|
|
}
|
|
}
|
|
|
|
androidTestPlatform {
|
|
java.srcDirs = ['platform/test/src']
|
|
}
|
|
|
|
androidTestGingerbreadCompat {
|
|
java.srcDirs = [
|
|
'gingerbread/test/instrumentation/src',
|
|
'recyclerview/test/instrumentation/src'
|
|
]
|
|
res.srcDirs = ['recyclerview/test/instrumentation/res']
|
|
}
|
|
|
|
test {
|
|
java.srcDirs = ['test/robotest/src']
|
|
|
|
dependencies {
|
|
testCompile 'org.robolectric:robolectric:3.+'
|
|
testCompile 'org.robolectric:shadows-core:3.+'
|
|
testCompile 'junit:junit:4.+'
|
|
testCompile 'org.mockito:mockito-core:1.9.5'
|
|
// Workaround for https://github.com/robolectric/robolectric/issues/2566
|
|
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
|
|
}
|
|
}
|
|
|
|
testGingerbreadCompat {
|
|
java.srcDirs = ['gingerbread/test/robotest/src', 'recyclerview/test/robotest/src']
|
|
}
|
|
}
|
|
android.defaultConfig.testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
android.lintOptions {
|
|
abortOnError true
|
|
htmlReport true
|
|
textOutput 'stderr'
|
|
textReport true
|
|
warningsAsErrors true
|
|
xmlReport false
|
|
}
|
|
// Run lint for all variants
|
|
android.libraryVariants.all { variant ->
|
|
variant.assemble.dependsOn(tasks.findByName('lint'))
|
|
}
|
|
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}"
|
|
}
|
|
}
|
|
}
|
|
}
|