Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/#781 create results dir #785

Merged
merged 8 commits into from
May 16, 2020
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)