Skip to content

Commit

Permalink
pull coverage file using dadb
Browse files Browse the repository at this point in the history
  • Loading branch information
karthyks committed Oct 5, 2023
1 parent f8ca372 commit c8f7d65
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions vendor/vendor-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
testImplementation(project(":vendor:vendor-test"))
testImplementation(TestLibraries.kluent)
testImplementation(TestLibraries.mockitoKotlin)
implementation("dev.mobile:dadb:1.2.7")
testImplementation(TestLibraries.spekAPI)
testRuntime(TestLibraries.spekJUnitPlatformEngine)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import com.android.ddmlib.ShellCommandUnresponsiveException
import com.android.ddmlib.TimeoutException
import com.android.ddmlib.testrunner.TestIdentifier
import com.malinskiy.marathon.log.MarathonLogging
import dadb.Dadb
import dadb.adbserver.AdbServer
import java.io.File

import java.io.IOException

Expand All @@ -32,6 +35,21 @@ class RemoteFileManager(
device.pullFile(remoteFilePath, localFilePath)
}

fun pullCoverageFile(remoteFilePath: String, localFile: File) {
runCatching {
val adb = AdbServer.createDadb(
adbServerHost = "localhost",
adbServerPort = 5037,
deviceQuery = "host:transport:${device.serialNumber}"
)
adb.pull(localFile, remoteFilePath)
}.onSuccess {
logger.debug { "Pulling file thru DADB is success" }
}.onFailure {
logger.error(it) { "Failed pulling file from DADB" }
}
}

fun createRemoteDirectory() {
executeCommand("mkdir $outputDir", "Could not create remote directory: $outputDir")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestCoverageResultListener(
val remoteFilePath = device.fileManager.remoteCoverageForTest()
logger.debug { "Pulling from $remoteFilePath" }
val millis = measureTimeMillis {
device.fileManager.pullFile(remoteFilePath, localCoverageFile.toString())
device.fileManager.pullCoverageFile(remoteFilePath, localCoverageFile)
}
logger.debug { "Pulling file finished in ${millis}ms $remoteFilePath " }
attachmentListeners.forEach {
Expand Down

0 comments on commit c8f7d65

Please sign in to comment.