-
Notifications
You must be signed in to change notification settings - Fork 45
#125 Report Path sanitization #126
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import com.google.gson.Gson | |
import rx.Observable | ||
import rx.schedulers.Schedulers | ||
import java.io.File | ||
import java.util.* | ||
import java.util.Date | ||
import java.util.concurrent.TimeUnit | ||
|
||
sealed class Exit(val code: Int, val message: String?) { | ||
|
@@ -90,7 +90,7 @@ fun main(rawArgs: Array<String>) { | |
.flatMap { adbDeviceTestRun -> | ||
writeJunit4Report( | ||
suite = adbDeviceTestRun.toSuite(args.testPackage), | ||
outputFile = File(File(args.outputDirectory, "junit4-reports"), "${device.id}.xml") | ||
outputFile = File(File(args.outputDirectory, "junit4-reports"), "${device.sanitizedId()}.xml") | ||
).toSingleDefault(adbDeviceTestRun) | ||
} | ||
.subscribeOn(Schedulers.io()) | ||
|
@@ -190,7 +190,9 @@ data class Device( | |
val id: String, | ||
val logcat: File, | ||
val instrumentationOutput: File | ||
) | ||
){ | ||
fun sanitizedId() = id.replace(":","-") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a property would look better, but I don't have strong opinion :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need tests btw :) |
||
} | ||
|
||
fun AdbDeviceTestRun.toSuite(testPackage: String): Suite = Suite( | ||
testPackage = testPackage, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
package com.gojuno.composer | ||
|
||
import com.gojuno.commander.android.* | ||
import com.gojuno.commander.android.AdbDevice | ||
import com.gojuno.commander.android.adb | ||
import com.gojuno.commander.android.log | ||
import com.gojuno.commander.android.pullFolder | ||
import com.gojuno.commander.android.redirectLogcatToFile | ||
import com.gojuno.commander.os.Notification | ||
import com.gojuno.commander.os.nanosToHumanReadableTime | ||
import com.gojuno.commander.os.process | ||
|
@@ -38,6 +42,8 @@ data class AdbDeviceTest( | |
} | ||
} | ||
|
||
fun AdbDevice.sanitizedId() = id.replace(":","-") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it would be great to create simple data class for id with an extension There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not good, we shouldn't duplicate implementation, it'll be easy to de-sync them |
||
|
||
fun AdbDevice.runTests( | ||
testPackageName: String, | ||
testRunnerClass: String, | ||
|
@@ -48,7 +54,7 @@ fun AdbDevice.runTests( | |
): Single<AdbDeviceTestRun> { | ||
|
||
val adbDevice = this | ||
val logsDir = File(File(outputDir, "logs"), adbDevice.id) | ||
val logsDir = File(File(outputDir, "logs"), adbDevice.sanitizedId()) | ||
val instrumentationOutputFile = File(logsDir, "instrumentation.output") | ||
|
||
val runTests = process( | ||
|
@@ -157,7 +163,7 @@ data class PulledFiles( | |
private fun pullTestFiles(adbDevice: AdbDevice, test: InstrumentationTest, outputDir: File, verboseOutput: Boolean): Single<PulledFiles> = Single | ||
// TODO: Add support for spoon files dir. | ||
.fromCallable { | ||
File(File(File(outputDir, "screenshots"), adbDevice.id), test.className).apply { mkdirs() } | ||
File(File(File(outputDir, "screenshots"), adbDevice.sanitizedId()), test.className).apply { mkdirs() } | ||
} | ||
.flatMap { screenshotsFolderOnHostMachine -> | ||
adbDevice | ||
|
@@ -225,3 +231,4 @@ private fun saveLogcat(adbDevice: AdbDevice, logsDir: File): Observable<Pair<Str | |
private fun logcatFileForDevice(logsDir: File) = File(logsDir, "full.logcat") | ||
|
||
private fun logcatFileForTest(logsDir: File, className: String, testName: String): File = File(File(logsDir, className), "$testName.logcat") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, this might break someones report parsing, we should emphasize this in release notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also an edge case when filenames for multiple devices will be equal after sanitization e.g. both
123:456
and123-456
.