diff --git a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt index a4f15b21ca..237f018d9d 100644 --- a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt @@ -43,7 +43,7 @@ class AndroidArgs( private val gcloud = gcloudYml.gcloud override val resultsBucket: String override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo - override val testTimeout = gcloud.timeout + override val testTimeout = cli?.timeout ?: gcloud.timeout override val async = gcloud.async override val projectId = gcloud.project override val resultsHistoryName = gcloud.resultsHistoryName diff --git a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt index ab5bd8876b..b30d276866 100644 --- a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt @@ -35,7 +35,7 @@ class IosArgs( private val gcloud = gcloudYml.gcloud override val resultsBucket: String override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo - override val testTimeout = gcloud.timeout + override val testTimeout = cli?.timeout ?: gcloud.timeout override val async = gcloud.async override val projectId = gcloud.project override val resultsHistoryName = gcloud.resultsHistoryName diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidRunCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidRunCommand.kt index 38c66409bf..9e55754e82 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidRunCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidRunCommand.kt @@ -129,4 +129,10 @@ class AndroidRunCommand : Runnable { @Option(names = ["--no-record-video"], description = ["""Disable video recording during the test. See --record-video to enable."""]) var noRecordVideo: Boolean? = null + + @Option(names = ["--timeout"], description = ["""The max time this test execution can run before it is cancelled + |(default: 15m). It does not include any time necessary to prepare and clean up the target device. The maximum + |possible testing time is 30m on physical devices and 60m on virtual devices. The TIMEOUT units can be h, m, + | or s. If no unit is given, seconds are assumed. """]) + var timeout: String? = null } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosRunCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosRunCommand.kt index ca2c0a4f2e..9e76342d1a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosRunCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosRunCommand.kt @@ -48,4 +48,10 @@ class IosRunCommand : Runnable { @Option(names = ["--no-record-video"], description = ["""Disable video recording during the test. See --record-video to enable."""]) var noRecordVideo: Boolean? = null + + @Option(names = ["--timeout"], description = ["""The max time this test execution can run before it is cancelled + |(default: 15m). It does not include any time necessary to prepare and clean up the target device. The maximum + |possible testing time is 30m on physical devices and 60m on virtual devices. The TIMEOUT units can be h, m, + | or s. If no unit is given, seconds are assumed. """]) + var timeout: String? = null } diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt index e739688b2d..b1d6608318 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt @@ -561,4 +561,19 @@ AndroidArgs assertThat(AndroidArgs.load(yaml).recordVideo).isTrue() assertThat(AndroidArgs.load(yaml, cli).recordVideo).isFalse() } + + @Test + fun cli_timeout() { + val cli = AndroidRunCommand() + CommandLine(cli).parse("--timeout=1m") + + val yaml = """ + gcloud: + app: $appApk + test: $testApk + timeout: 2m + """ + assertThat(AndroidArgs.load(yaml).testTimeout).isEqualTo("2m") + assertThat(AndroidArgs.load(yaml, cli).testTimeout).isEqualTo("1m") + } } diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 738858cbac..b25eddb280 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -281,4 +281,19 @@ IosArgs assertThat(IosArgs.load(yaml).recordVideo).isTrue() assertThat(IosArgs.load(yaml, cli).recordVideo).isFalse() } + + @Test + fun cli_timeout() { + val cli = IosRunCommand() + CommandLine(cli).parse("--timeout=1m") + + val yaml = """ + gcloud: + test: $testPath + xctestrun-file: $xctestrunFile + timeout: 2m + """ + assertThat(IosArgs.load(yaml).testTimeout).isEqualTo("2m") + assertThat(IosArgs.load(yaml, cli).testTimeout).isEqualTo("1m") + } } diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidRunCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidRunCommandTest.kt index 0a7f40b107..bee91f245d 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidRunCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidRunCommandTest.kt @@ -73,6 +73,7 @@ class AndroidRunCommandTest { assertThat(cmd.resultsBucket).isNull() assertThat(cmd.recordVideo).isNull() assertThat(cmd.noRecordVideo).isNull() + assertThat(cmd.timeout).isNull() } @Test @@ -199,4 +200,12 @@ class AndroidRunCommandTest { assertThat(cmd.noRecordVideo).isTrue() } + + @Test + fun timeout_parse() { + val cmd = AndroidRunCommand() + CommandLine(cmd).parse("--timeout=1m") + + assertThat(cmd.timeout).isEqualTo("1m") + } } diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosRunCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosRunCommandTest.kt index a0b35e30b3..2c6ab42c49 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosRunCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosRunCommandTest.kt @@ -60,6 +60,7 @@ class IosRunCommandTest { assertThat(cmd.resultsBucket).isNull() assertThat(cmd.recordVideo).isNull() assertThat(cmd.noRecordVideo).isNull() + assertThat(cmd.timeout).isNull() } @Test @@ -85,4 +86,12 @@ class IosRunCommandTest { assertThat(cmd.noRecordVideo).isTrue() } + + @Test + fun timeout_parse() { + val cmd = IosRunCommand() + CommandLine(cmd).parse("--timeout=1m") + + assertThat(cmd.timeout).isEqualTo("1m") + } }