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

Fail fast when results-dir is incorrect #772

Merged
merged 4 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## next (unreleased)
- [#772](https://github.com/Flank/flank/pull/772) Fail fast when results-dir is incorrect. ([jan-gogo](https://github.com/jan-gogo))
- [#757](https://github.com/Flank/flank/pull/767) Reduce memory usage by using Reader and Writer instead of ByteArrays. ([jan-gogo](https://github.com/jan-gogo))
- [#763](https://github.com/Flank/flank/pull/763) Use "localhost" as default for hostname to fix backward compatibility. ([jan-gogo](https://github.com/jan-gogo))
- [#757](https://github.com/Flank/flank/pull/757) Print version and revision before each command. ([jan-gogo](https://github.com/jan-gogo))
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 @@ -45,7 +45,7 @@ class AndroidArgs(
) : IArgs {
private val gcloud = gcloudYml.gcloud
override val resultsBucket: String
override val resultsDir = cli?.resultsDir ?: gcloud.resultsDir
override val resultsDir = (cli?.resultsDir ?: gcloud.resultsDir)?.also { assertFileExists(it, "from results-dir") }
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal fun beforeRunTests(args: IArgs): Pair<StopWatch, String> {

// Avoid spamming the results/ dir with temporary files from running the test suite.
if (FtlConstants.useMock)
deleteMockResultDirOnShotDown(args, runGcsPath)
deleteMockResultDirOnShutDown(args, runGcsPath)

if (args.useLocalResultDir()) {
// Only one result is stored when using --local-result-dir
Expand All @@ -36,7 +36,7 @@ private fun assertMockUrl() {
if (!GcToolResults.service.rootUrl.contains(FtlConstants.localhost)) throw RuntimeException("expected localhost in GcToolResults")
}

private fun deleteMockResultDirOnShotDown(args: IArgs, runGcsPath: String) {
private fun deleteMockResultDirOnShutDown(args: IArgs, runGcsPath: String) {
Runtime.getRuntime().addShutdownHook(Thread {
File(args.localResultDir, runGcsPath).deleteRecursively()
})
Expand Down
18 changes: 14 additions & 4 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -969,20 +969,30 @@ 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()
CommandLine(cli).parseArgs("--results-dir=b")
CommandLine(cli).parseArgs("--results-dir=build")

val yaml = """
gcloud:
app: $appApk
test: $testApk
results-dir: a
results-dir: results
"""

assertThat(AndroidArgs.load(yaml).resultsDir).isEqualTo("a")
assertThat(AndroidArgs.load(yaml, cli).resultsDir).isEqualTo("b")
assertThat(AndroidArgs.load(yaml).resultsDir).isEqualTo("results")
assertThat(AndroidArgs.load(yaml, cli).resultsDir).isEqualTo("build")
}

@Test
Expand Down