Skip to content

Commit

Permalink
Bug/#781 create results dir (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfilipow92 authored May 16, 2020
1 parent 9eb491d commit ceabb78
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## next (unreleased)

- [#781](https://github.com/Flank/flank/pull/781) Remove local exists check on cloud results-dir. Fixes crash when results-dir is set by the user. ([adamfilipow92](https://github.com/adamfilipow92))
- [#656](https://github.com/Flank/flank/issues/656) Improve error message reporting. ([adamfilipow92](https://github.com/adamfilipow92))
- [#783](https://github.com/Flank/flank/pull/783) Use legacy results for iOS by default. ([pawelpasterz](https://github.com/pawelpasterz))

Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AndroidArgs(

private val gcloud = gcloudYml.gcloud
override val resultsBucket: String
override val resultsDir = (cli?.resultsDir ?: gcloud.resultsDir)?.also { assertFileExists(it, "from results-dir") }
override val resultsDir = (cli?.resultsDir ?: gcloud.resultsDir)
override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo
override val testTimeout = cli?.timeout ?: gcloud.timeout
override val async = cli?.async ?: gcloud.async
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/test/kotlin/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fun main() {
// run "gradle check" to generate required fixtures
val projectId = System.getenv("GOOGLE_CLOUD_PROJECT")
?: "YOUR PROJECT ID"
val quantity = "multiple"
val type = "parse-error"
val quantity = "single"
val type = "success"

// Bugsnag keeps the process alive so we must call exitProcess
// https://github.com/bugsnag/bugsnag-java/issues/151
Expand Down
33 changes: 23 additions & 10 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.mockk.mockkObject
import io.mockk.unmockkAll
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Rule
Expand All @@ -27,6 +28,9 @@ import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import picocli.CommandLine
import java.io.StringReader
import java.nio.file.Files
import java.nio.file.Paths
import java.util.UUID

@Suppress("TooManyFunctions")
@RunWith(FlankTestRunner::class)
Expand Down Expand Up @@ -969,16 +973,6 @@ AndroidArgs
assertThat(AndroidArgs.load(yaml, cli).testTargetsAlwaysRun).isEqualTo(arrayListOf("com.A", "com.B"))
}

@Test(expected = FlankFatalError::class)
fun `cli resultsDir fail if not exist`() {
val yaml = """
gcloud:
app: $appApk
test: $testApk
results-dir: not_exist
"""
AndroidArgs.load(yaml)
}
@Test
fun `cli resultsDir`() {
val cli = AndroidRunCommand()
Expand Down Expand Up @@ -1252,6 +1246,25 @@ AndroidArgs
val parsedYml = AndroidArgs.load(yaml)
runBlocking { runAndroidTests(parsedYml) }
}

@Test
fun `results-dir (cloud directory) should not throw if it doesn't exist locally`() {
val resultsDir = UUID.randomUUID().toString()
val directoryPath = Paths.get(resultsDir)
if (Files.exists(directoryPath)) {
Assert.fail("Test directory ($resultsDir) shouldn't exists! It's a remote directory.")
}
val yaml = """
gcloud:
app: $appApk
test: $testApk
results-dir: $resultsDir
""".trimIndent()
AndroidArgs.load(yaml)
if (Files.exists(directoryPath)) {
Assert.fail("Test directory ($resultsDir) shouldn't be created! It's a remote directory on the cloud!")
}
}
}

private fun AndroidArgs.Companion.load(yamlData: String, cli: AndroidRunCommand? = null): AndroidArgs = load(StringReader(yamlData), cli)

0 comments on commit ceabb78

Please sign in to comment.