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

Commit

Permalink
Added logging for stop steps. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunikkk authored and artem-zinnatullin committed Jul 4, 2017
1 parent 71e97b9 commit c9f41c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
32 changes: 20 additions & 12 deletions swarmer/src/main/kotlin/com/gojuno/swarmer/Emulators.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,27 @@ fun stopAllEmulators(
args: Commands.Stop,
connectedEmulators: () -> Single<Set<AdbDevice>> = ::connectedEmulators,
completableProcess: (List<String>, Pair<Int, TimeUnit>?) -> Completable = ::completableProcess
) = connectedEmulators()
.map { emulators ->
emulators.map { emulator ->
completableProcess(
listOf(adb, "-s", emulator.id, "emu", "kill"),
args.timeoutSeconds to SECONDS
)
) {
val startTime = System.nanoTime()

connectedEmulators()
.map { emulators ->
log("Stopping running emulators: $emulators.")
emulators.map { emulator ->
completableProcess(
listOf(adb, "-s", emulator.id, "emu", "kill"),
args.timeoutSeconds to SECONDS
)
.doOnCompleted { log("Stopped emulator $emulator.") }
}
}
}
.flatMapCompletable(Completable::merge)
.doOnError { log("Error during all emulators stop, error = $it") }
.doOnCompleted { log("All emulators stopped") }
.await()
.flatMapCompletable(Completable::merge)
.doOnError { log("Error during stopping emulators, error = $it.") }
.doOnCompleted { log("All emulators stopped.") }
.await()

log("Swarmer: - \"My job is done here, took ${(System.nanoTime() - startTime).nanosAsSeconds()} seconds, bye bye.\"")
}

private fun completableProcess(args: List<String>, timeout: Pair<Int, TimeUnit>?) =
process(args, timeout)
Expand Down
16 changes: 0 additions & 16 deletions swarmer/src/test/kotlin/com/gojuno/swarmer/ArgsSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.gojuno.swarmer

import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.SpecBody
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on

Expand Down Expand Up @@ -31,21 +30,6 @@ class ArgsSpec : Spek({
}
}

fun SpecBody.onEmulatorNameVariants() {
listOf("a", "b").forEach {
// evaluateBody(it)
if (it == "a") {
it("is a") {

}
} else {
it("is b") {

}
}
}
}

on("parse multiple args") {

val result by memoized {
Expand Down

0 comments on commit c9f41c1

Please sign in to comment.