Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Added flag to keep output. (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunikkk authored Oct 24, 2017
1 parent bd6c738 commit bdff777
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
14 changes: 11 additions & 3 deletions composer/src/main/kotlin/com/gojuno/composer/Args.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,33 @@ data class Args(
names = arrayOf("--verbose-output"),
required = false,
arity = 1,
description = "Either `true` or `false` to enable/disable verbose output for Swarmer. `false` by default.",
description = "Either `true` or `false` to enable/disable verbose output for Composer. `false` by default.",
order = 7
)
var verboseOutput: Boolean = false,

@Parameter(
names = arrayOf("--keep-output-on-exit"),
required = false,
description = "Keep output on exit. False by default.",
order = 8
)
var keepOutputOnExit: Boolean = false,

@Parameter(
names = arrayOf("--devices"),
required = false,
variableArity = true,
description = "Connected devices/emulators that will be used to run tests against. If not passed — tests will run on all connected devices/emulators. Specifying both `--devices` and `--device-pattern` will result in an error. Usage example: `--devices emulator-5554 emulator-5556`.",
order = 8
order = 9
)
var devices: List<String> = emptyList(),

@Parameter(
names = arrayOf("--device-pattern"),
required = false,
description = "Connected devices/emulators that will be used to run tests against. If not passed — tests will run on all connected devices/emulators. Specifying both `--device-pattern` and `--devices` will result in an error. Usage example: `--device-pattern \"somePatterns\"`.",
order = 9
order = 10
)
var devicePattern: String = ""
)
Expand Down
3 changes: 2 additions & 1 deletion composer/src/main/kotlin/com/gojuno/composer/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ fun main(rawArgs: Array<String>) {
testRunnerClass = args.testRunner,
instrumentationArguments = instrumentationArguments.formatInstrumentationArguments(),
outputDir = File(args.outputDirectory),
verboseOutput = args.verboseOutput
verboseOutput = args.verboseOutput,
keepOutput = args.keepOutputOnExit
)
.flatMap { adbDeviceTestRun ->
writeJunit4Report(
Expand Down
6 changes: 4 additions & 2 deletions composer/src/main/kotlin/com/gojuno/composer/TestRun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fun AdbDevice.runTests(
testRunnerClass: String,
instrumentationArguments: String,
outputDir: File,
verboseOutput: Boolean
verboseOutput: Boolean,
keepOutput: Boolean
): Single<AdbDeviceTestRun> {

val adbDevice = this
Expand All @@ -57,7 +58,8 @@ fun AdbDevice.runTests(
"shell", "am instrument -w -r $instrumentationArguments $testPackageName/$testRunnerClass"
),
timeout = null,
redirectOutputTo = instrumentationOutputFile
redirectOutputTo = instrumentationOutputFile,
keepOutputOnExit = keepOutput
).share()

@Suppress("destructure")
Expand Down
13 changes: 11 additions & 2 deletions composer/src/test/kotlin/com/gojuno/composer/ArgsSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ArgsSpec : Spek({
outputDirectory = "composer-output",
instrumentationArguments = emptyList(),
verboseOutput = false,
keepOutputOnExit = false,
devices = emptyList(),
devicePattern = ""
))
Expand Down Expand Up @@ -100,7 +101,6 @@ class ArgsSpec : Spek({
it("parses correctly device ids") {
assertThat(args.devices).isEqualTo(listOf("emulator-5554"))
}

}

context("parse args with passed two --devices") {
Expand All @@ -112,7 +112,6 @@ class ArgsSpec : Spek({
it("parses correctly two device ids") {
assertThat(args.devices).isEqualTo(listOf("emulator-5554", "emulator-5556"))
}

}

context("parse args with passed --device-pattern") {
Expand All @@ -135,4 +134,14 @@ class ArgsSpec : Spek({
}
}

context("parse args with --keep-output-on-exit") {

val args by memoized {
parseArgs(rawArgsWithOnlyRequiredFields + "--keep-output-on-exit")
}

it("parses --keep-output-on-exit correctly") {
assertThat(args.keepOutputOnExit).isEqualTo(true)
}
}
})
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext.versions = [

rxJava : '1.3.0',
jCommander : '1.71',
commander : '0.1.1',
commander : '0.1.2',
apacheCommonsIo : '2.5',
apacheCommonsLang: '3.5',
gson : '2.8.0',
Expand Down

0 comments on commit bdff777

Please sign in to comment.