Skip to content

Commit

Permalink
use new zip operator so that all inputs are providers
Browse files Browse the repository at this point in the history
  • Loading branch information
joshschriever committed Aug 13, 2020
1 parent f2abf7a commit 4bf9ba7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 18 additions & 19 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ internal abstract class GordonTestTask @Inject constructor(
@get:Input
internal val instrumentationPackage: Property<String> = objects.property()

@get:Input
internal val instrumentationRunnerOptions: InstrumentationRunnerOptions
get() {
val options = androidInstrumentationRunnerOptions.get()
val extensionRunner = extensionTestInstrumentationRunner.get()

return if (extensionRunner.isNotBlank()) options.copy(testInstrumentationRunner = extensionRunner)
else options
}

@get:Input
internal val testFilters: List<String>
get() = (commandlineTestFilter.get().takeIf { it.isNotBlank() } ?: extensionTestFilter.get())
.split(',')
.filter { it.isNotBlank() }
.map { it.replace('#', '.') }

@get:Input
internal val poolingStrategy: Property<PoolingStrategy> = objects.property()

Expand All @@ -89,6 +72,22 @@ internal abstract class GordonTestTask @Inject constructor(

internal val androidInstrumentationRunnerOptions: Property<InstrumentationRunnerOptions> = objects.property()

@get:Input
internal val testFilters: Provider<List<String>> =
commandlineTestFilter.zip(extensionTestFilter) { commandlineTestFilter, extensionTestFilter ->
(commandlineTestFilter.takeIf { it.isNotBlank() } ?: extensionTestFilter)
.split(',')
.filter { it.isNotBlank() }
.map { it.replace('#', '.') }
}

@get:Input
internal val instrumentationRunnerOptions: Provider<InstrumentationRunnerOptions> =
androidInstrumentationRunnerOptions.zip(extensionTestInstrumentationRunner) { options, extensionRunner ->
if (extensionRunner.isNotBlank()) options.copy(testInstrumentationRunner = extensionRunner)
else options
}

@OutputDirectory
val testResultsDirectory: Provider<Directory> = projectLayout.buildDirectory.dir("test-results/$name")

Expand All @@ -115,7 +114,7 @@ internal abstract class GordonTestTask @Inject constructor(
tabletShortestWidthDp.get().takeIf { it > -1 }
).bind()
val testCases = loadTestSuite(instrumentationApk.get().asFile).bind()
.filter { it.matchesFilter(testFilters) }
.filter { it.matchesFilter(testFilters.get()) }

when {
testCases.isEmpty() -> raiseError<Unit>(IllegalStateException("No test cases found")).bind()
Expand Down Expand Up @@ -153,7 +152,7 @@ internal abstract class GordonTestTask @Inject constructor(
dispatcher = Dispatchers.Default,
logger = logger,
instrumentationPackage = instrumentationPackage.get(),
instrumentationRunnerOptions = instrumentationRunnerOptions,
instrumentationRunnerOptions = instrumentationRunnerOptions.get(),
allTestCases = testCases,
allPools = pools,
retryQuota = retryQuota.get(),
Expand Down

0 comments on commit 4bf9ba7

Please sign in to comment.