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

Added option to stop emulators. (#15) #16

Merged
merged 3 commits into from
Jun 28, 2017

Conversation

yunikkk
Copy link
Contributor

@yunikkk yunikkk commented Jun 22, 2017

No description provided.

JCommander(JCommanderArgs()).usage()
System.exit(0)
}

if (COMMAND_STOP_NAMES.firstOrNull { rawArgs.contains(it) } != null) {
stopAllEmulators().toBlocking().firstOrDefault(Unit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, let's move it to main(), parseArgs() should definitely not be doing anything like that

Maybe return sealed class of parse result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thought about it. Decided to go easy way, though=\

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, it'd never easy man, never easy

.map { emulator ->
process(
listOf(adb, "-s", emulator.id, "emu", "kill"),
timeout = 5 to SECONDS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm pretty sure we'll overpass this timeout on our highloaded CI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess something like 15 seconds would be a better default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, lets try 15

private fun connectedEmulators(): Observable<Iterable<AdbDevice>> =
connectedAdbDevices().map { it.filter { it.isEmulator } }

fun stopAllEmulators(): Observable<Unit> =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Completable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@yunikkk yunikkk force-pushed the add-stop-emulator-option branch from 3c7b72c to b795c4e Compare June 26, 2017 06:52
@@ -2,7 +2,7 @@ ext.versions = [
kotlin : '1.1.1',

rxJava : '1.2.9',
jCommander : '1.66',
jCommander : '1.71',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old version was hiding JCommander.newBuilder

@yunikkk yunikkk force-pushed the add-stop-emulator-option branch 2 times, most recently from 49aacb8 to 20861e8 Compare June 26, 2017 10:24
Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More tests please, other than that LGTM!

@yunikkk yunikkk force-pushed the add-stop-emulator-option branch from 20861e8 to b32d634 Compare June 28, 2017 16:18
fun parseStartArguments(rawArgs: List<String>): List<Commands.Start> =
rawArgs
.subList(1, rawArgs.size) // skip command
.fold(ArrayList<ArrayList<String>>()) { accumulator, value ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh finally

.map { it.doOnNext { log("Emulator $it is ready.") } }

Observable.zip(startEmulators, { startedEmulator -> startedEmulator })
rawArgs.toList().apply {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is awesome!

)))
}
}

fun SpecBody.onEmulatorNameVariants() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, we need to del this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO

import rx.Single
import java.util.concurrent.TimeUnit

class EmulatorsSpec : Spek({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants