Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz authored and mergify-bot committed Aug 13, 2021
1 parent 567061c commit 489ba8a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
11 changes: 11 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,14 @@ fun String.normalizeFilePath(): String =
fun List<String>.normalizeToTestTargets(): ShardChunks =
if (isEmpty()) emptyList()
else map { it.split(',', ';') }

fun getEnv(name: String): String? = System.getenv(name)

fun List<String>.parseEnvsIfNeeded() = this
.partition { it.startsWith("$") }
.let { (envs, commonTestTargets) ->
commonTestTargets + envs
.mapNotNull { getEnv(it.drop(1)) }
.flatMap { it.split(",") }
.map { it.trim() }
}
1 change: 0 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/CreateAndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ftl.config.android.AndroidFlankConfig
import ftl.config.android.AndroidGcloudConfig
import ftl.run.common.fromJson
import ftl.run.model.AndroidTestShards
import ftl.util.parseEnvsIfNeeded
import ftl.util.require
import java.nio.file.Paths

Expand Down
1 change: 0 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/CreateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ftl.args.yml.Type
import ftl.config.IosConfig
import ftl.config.ios.IosFlankConfig
import ftl.config.ios.IosGcloudConfig
import ftl.util.parseEnvsIfNeeded
import ftl.util.require

fun createIosArgs(
Expand Down
11 changes: 0 additions & 11 deletions test_runner/src/main/kotlin/ftl/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,3 @@ fun <T> KMutableProperty<T?>.require() =
fun getGACPathOrEmpty(): String = System.getenv("GOOGLE_APPLICATION_CREDENTIALS").orEmpty()

fun saveToFlankLinks(vararg links: String) = File("flank-links.log").writeText(links.joinToString(System.lineSeparator()))

fun getEnv(name: String): String? = System.getenv(name)

fun List<String>.parseEnvsIfNeeded() = this
.partition { it.startsWith("$") }
.let { (envs, commonTestTargets) ->
commonTestTargets + envs
.mapNotNull { getEnv(it.drop(1)) }
.flatMap { it.split(",") }
.map { it.trim() }
}
3 changes: 1 addition & 2 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsFileTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ftl.test.util.TestHelper.absolutePath
import ftl.test.util.TestHelper.assert
import ftl.test.util.TestHelper.getPath
import ftl.test.util.TestHelper.getString
import ftl.util.getEnv
import io.mockk.every
import io.mockk.mockkStatic
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -107,7 +106,7 @@ class AndroidArgsFileTest {

@Test
fun `should parse test-targets from env`() {
mockkStatic("ftl.util.Utils")
mockkStatic("ftl.args.ArgsHelperKt")
every { getEnv("FROM_ENV") } returns "class from.env.Class,notAnnotation from.env.Annotation"
val config = AndroidArgs.load(localYamlFile)
assertThat(config.testTargets).containsExactly(
Expand Down

0 comments on commit 489ba8a

Please sign in to comment.