From f586f9f85fd3f8c154c7477cc630f809c29186bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20G=C3=B3ral?= Date: Mon, 22 Mar 2021 12:13:31 +0100 Subject: [PATCH 1/4] Extract logic from cli to domain --- .../src/main/kotlin/ftl/cli/AuthCommand.kt | 8 +-- .../main/kotlin/ftl/cli/FirebaseCommand.kt | 8 +-- .../main/kotlin/ftl/cli/auth/LoginCommand.kt | 12 ++-- .../kotlin/ftl/cli/firebase/CancelCommand.kt | 13 ++-- .../kotlin/ftl/cli/firebase/RefreshCommand.kt | 24 +++---- .../kotlin/ftl/cli/firebase/TestCommand.kt | 14 +--- .../ftl/cli/firebase/test/AndroidCommand.kt | 16 +---- .../ftl/cli/firebase/test/IPBlocksCommand.kt | 7 +- .../ftl/cli/firebase/test/IosCommand.kt | 16 +---- .../firebase/test/NetworkProfilesCommand.kt | 7 +- .../firebase/test/ProvidedSoftwareCommand.kt | 7 +- .../test/android/AndroidDoctorCommand.kt | 39 ++++++----- .../test/android/AndroidLocalesCommand.kt | 7 +- .../test/android/AndroidModelsCommand.kt | 7 +- .../android/AndroidOrientationsCommand.kt | 7 +- .../test/android/AndroidRunCommand.kt | 66 ++++--------------- .../android/AndroidTestEnvironmentCommand.kt | 41 +++++------- .../test/android/AndroidVersionsCommand.kt | 7 +- .../AndroidLocalesDescribeCommand.kt | 26 ++++---- .../AndroidLocalesListCommand.kt | 28 ++++---- .../models/AndroidModelDescribeCommand.kt | 36 +++++----- .../models/AndroidModelsListCommand.kt | 28 ++++---- .../AndroidOrientationsListCommand.kt | 28 ++++---- .../AndroidVersionsDescribeCommand.kt | 26 ++++---- .../versions/AndroidVersionsListCommand.kt | 28 ++++---- .../cli/firebase/test/ios/IosDoctorCommand.kt | 39 ++++++----- .../firebase/test/ios/IosLocalesCommand.kt | 7 +- .../cli/firebase/test/ios/IosModelsCommand.kt | 7 +- .../test/ios/IosOrientationsCommand.kt | 7 +- .../cli/firebase/test/ios/IosRunCommand.kt | 60 ++++------------- .../test/ios/IosTestEnvironmentCommand.kt | 41 +++++------- .../firebase/test/ios/IosVersionsCommand.kt | 7 +- .../IosLocalesDescribeCommand.kt | 26 ++++---- .../configuration/IosLocalesListCommand.kt | 28 ++++---- .../ios/models/IosModelDescribeCommand.kt | 36 +++++----- .../test/ios/models/IosModelsListCommand.kt | 28 ++++---- .../IosOrientationsListCommand.kt | 28 ++++---- .../versions/IosVersionsDescribeCommand.kt | 26 ++++---- .../ios/versions/IosVersionsListCommand.kt | 28 ++++---- .../test/ipblocks/IPBlocksListCommand.kt | 12 ++-- .../NetworkProfilesDescribeCommand.kt | 17 +++-- .../NetworkProfilesListCommand.kt | 13 ++-- .../ProvidedSoftwareListCommand.kt | 12 ++-- .../main/kotlin/ftl/domain/CancelLastRun.kt | 10 +++ .../ftl/domain/DescribeAndroidLocales.kt | 17 +++++ .../ftl/domain/DescribeAndroidModels.kt | 17 +++++ .../domain/DescribeAndroidTestEnvironment.kt | 24 +++++++ .../ftl/domain/DescribeAndroidVersions.kt | 17 +++++ .../kotlin/ftl/domain/DescribeIosLocales.kt | 17 +++++ .../kotlin/ftl/domain/DescribeIosModels.kt | 17 +++++ .../ftl/domain/DescribeIosTestEnvironment.kt | 24 +++++++ .../kotlin/ftl/domain/DescribeIosVersions.kt | 17 +++++ .../ftl/domain/DescribeNetworkProfiles.kt | 14 ++++ .../kotlin/ftl/domain/ListAndroidLocales.kt | 14 ++++ .../kotlin/ftl/domain/ListAndroidModels.kt | 14 ++++ .../ftl/domain/ListAndroidOrientations.kt | 14 ++++ .../kotlin/ftl/domain/ListAndroidVersions.kt | 14 ++++ .../main/kotlin/ftl/domain/ListIPBlocks.kt | 10 +++ .../main/kotlin/ftl/domain/ListIosLocales.kt | 14 ++++ .../main/kotlin/ftl/domain/ListIosModels.kt | 14 ++++ .../kotlin/ftl/domain/ListIosOrientations.kt | 14 ++++ .../main/kotlin/ftl/domain/ListIosVersions.kt | 14 ++++ .../kotlin/ftl/domain/ListNetworkProfiles.kt | 11 ++++ .../kotlin/ftl/domain/ListProvidedSoftware.kt | 10 +++ .../kotlin/ftl/domain/LoginGoogleAccount.kt | 9 +++ .../main/kotlin/ftl/domain/RefreshLastRun.kt | 13 ++++ .../kotlin/ftl/domain/RunDoctorAndroid.kt | 17 +++++ .../main/kotlin/ftl/domain/RunDoctorIos.kt | 17 +++++ .../main/kotlin/ftl/domain/RunTestAndroid.kt | 63 ++++++++++++++++++ .../src/main/kotlin/ftl/domain/RunTestIos.kt | 52 +++++++++++++++ .../src/main/kotlin/ftl/util/CliCommand.kt | 9 +++ 71 files changed, 918 insertions(+), 507 deletions(-) create mode 100644 test_runner/src/main/kotlin/ftl/domain/CancelLastRun.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeIosModels.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeIosVersions.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/DescribeNetworkProfiles.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListIPBlocks.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListIosLocales.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListIosModels.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListIosVersions.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListNetworkProfiles.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/LoginGoogleAccount.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/RefreshLastRun.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/RunDoctorAndroid.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/RunDoctorIos.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt create mode 100644 test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt create mode 100644 test_runner/src/main/kotlin/ftl/util/CliCommand.kt diff --git a/test_runner/src/main/kotlin/ftl/cli/AuthCommand.kt b/test_runner/src/main/kotlin/ftl/cli/AuthCommand.kt index b358f789e8..6d14073b96 100644 --- a/test_runner/src/main/kotlin/ftl/cli/AuthCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/AuthCommand.kt @@ -1,7 +1,7 @@ package ftl.cli import ftl.cli.auth.LoginCommand -import picocli.CommandLine +import ftl.util.PrintHelp import picocli.CommandLine.Command @Command( @@ -13,8 +13,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class AuthCommand : Runnable { - override fun run() { - CommandLine.usage(AuthCommand(), System.out) - } -} +class AuthCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/FirebaseCommand.kt b/test_runner/src/main/kotlin/ftl/cli/FirebaseCommand.kt index 4b0cbcb0b4..c11261efde 100644 --- a/test_runner/src/main/kotlin/ftl/cli/FirebaseCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/FirebaseCommand.kt @@ -3,7 +3,7 @@ package ftl.cli import ftl.cli.firebase.CancelCommand import ftl.cli.firebase.RefreshCommand import ftl.cli.firebase.TestCommand -import picocli.CommandLine +import ftl.util.PrintHelp import picocli.CommandLine.Command @Command( @@ -16,8 +16,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class FirebaseCommand : Runnable { - override fun run() { - CommandLine.usage(FirebaseCommand(), System.out) - } -} +class FirebaseCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/auth/LoginCommand.kt b/test_runner/src/main/kotlin/ftl/cli/auth/LoginCommand.kt index 9dd306169b..3b6e90176f 100644 --- a/test_runner/src/main/kotlin/ftl/cli/auth/LoginCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/auth/LoginCommand.kt @@ -1,6 +1,7 @@ package ftl.cli.auth -import ftl.gc.UserAuth +import ftl.domain.LoginGoogleAccount +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -15,10 +16,9 @@ import picocli.CommandLine description = ["""Authenticates using your user account. For CI, a service account is recommended."""], usageHelpAutoWidth = true ) -class LoginCommand : Runnable { - override fun run() { - UserAuth().request() - } +class LoginCommand : + Runnable, + LoginGoogleAccount { @CommandLine.Option( names = ["-h", "--help"], @@ -26,4 +26,6 @@ class LoginCommand : Runnable { description = ["Prints this help message"] ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt index 14ca0ac02b..a9daddf605 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase -import ftl.args.AndroidArgs -import ftl.run.cancelLastRun +import ftl.domain.CancelLastRun +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -20,11 +20,12 @@ Reads in the matrix_ids.json file. Cancels any incomplete matrices. ], usageHelpAutoWidth = true ) -class CancelCommand : Runnable { - override fun run() { - cancelLastRun(AndroidArgs.default()) - } +class CancelCommand : + Runnable, + CancelLastRun { @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/RefreshCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/RefreshCommand.kt index 65af996618..1d1127d4c4 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/RefreshCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/RefreshCommand.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase -import ftl.args.AndroidArgs -import ftl.run.refreshLastRun +import ftl.domain.RefreshLastRun +import ftl.domain.invoke import kotlinx.coroutines.runBlocking import picocli.CommandLine.Command import picocli.CommandLine.Option @@ -22,16 +22,16 @@ Reads in the matrix_ids.json file. Refreshes any incomplete matrices. ], usageHelpAutoWidth = true ) -class RefreshCommand : Runnable { - override fun run() { - runBlocking { - refreshLastRun( - currentArgs = AndroidArgs.default(), - testShardChunks = emptyList() - ) - } - } +class RefreshCommand : + Runnable, + RefreshLastRun { - @Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = runBlocking { invoke() } } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt index a22405277c..80edc91628 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt @@ -1,11 +1,7 @@ package ftl.cli.firebase -import ftl.cli.firebase.test.AndroidCommand -import ftl.cli.firebase.test.IPBlocksCommand -import ftl.cli.firebase.test.IosCommand -import ftl.cli.firebase.test.NetworkProfilesCommand -import ftl.cli.firebase.test.ProvidedSoftwareCommand -import picocli.CommandLine +import ftl.cli.firebase.test.* +import ftl.util.PrintHelp import picocli.CommandLine.Command @Command( @@ -20,8 +16,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class TestCommand : Runnable { - override fun run() { - CommandLine.usage(TestCommand(), System.out) - } -} +class TestCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt index 85a9576ef0..bd5daa6c8e 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt @@ -1,13 +1,7 @@ package ftl.cli.firebase.test -import ftl.cli.firebase.test.android.AndroidDoctorCommand -import ftl.cli.firebase.test.android.AndroidLocalesCommand -import ftl.cli.firebase.test.android.AndroidModelsCommand -import ftl.cli.firebase.test.android.AndroidOrientationsCommand -import ftl.cli.firebase.test.android.AndroidRunCommand -import ftl.cli.firebase.test.android.AndroidTestEnvironmentCommand -import ftl.cli.firebase.test.android.AndroidVersionsCommand -import picocli.CommandLine +import ftl.cli.firebase.test.android.* +import ftl.util.PrintHelp import picocli.CommandLine.Command @Command( @@ -24,8 +18,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class AndroidCommand : Runnable { - override fun run() { - CommandLine.usage(AndroidCommand(), System.out) - } -} +class AndroidCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IPBlocksCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IPBlocksCommand.kt index d2091b72a2..e2334fa2ec 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IPBlocksCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IPBlocksCommand.kt @@ -1,6 +1,7 @@ package ftl.cli.firebase.test import ftl.cli.firebase.test.ipblocks.IPBlocksListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -10,8 +11,4 @@ import picocli.CommandLine header = ["Explore IP blocks used by Firebase Test Lab devices."], usageHelpAutoWidth = true ) -class IPBlocksCommand : Runnable { - override fun run() { - CommandLine.usage(IPBlocksCommand(), System.out) - } -} +class IPBlocksCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt index f9f725244e..4e414e36d1 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt @@ -1,13 +1,7 @@ package ftl.cli.firebase.test -import ftl.cli.firebase.test.ios.IosDoctorCommand -import ftl.cli.firebase.test.ios.IosLocalesCommand -import ftl.cli.firebase.test.ios.IosModelsCommand -import ftl.cli.firebase.test.ios.IosOrientationsCommand -import ftl.cli.firebase.test.ios.IosRunCommand -import ftl.cli.firebase.test.ios.IosTestEnvironmentCommand -import ftl.cli.firebase.test.ios.IosVersionsCommand -import picocli.CommandLine +import ftl.cli.firebase.test.ios.* +import ftl.util.PrintHelp import picocli.CommandLine.Command @Command( @@ -24,8 +18,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class IosCommand : Runnable { - override fun run() { - CommandLine.usage(IosCommand(), System.out) - } -} +class IosCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/NetworkProfilesCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/NetworkProfilesCommand.kt index 45617c4ae2..745a807fc6 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/NetworkProfilesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/NetworkProfilesCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test import ftl.cli.firebase.test.networkprofiles.NetworkProfilesDescribeCommand import ftl.cli.firebase.test.networkprofiles.NetworkProfilesListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -14,8 +15,4 @@ import picocli.CommandLine header = ["Explore network profiles available for testing."], usageHelpAutoWidth = true ) -class NetworkProfilesCommand : Runnable { - override fun run() { - CommandLine.usage(NetworkProfilesCommand(), System.out) - } -} +class NetworkProfilesCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt index 864eeb0f3f..dc1946c29f 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt @@ -1,6 +1,7 @@ package ftl.cli.firebase.test import ftl.cli.firebase.test.providedsoftware.ProvidedSoftwareListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -11,8 +12,4 @@ import picocli.CommandLine ], usageHelpAutoWidth = true ) -class ProvidedSoftwareCommand : Runnable { - override fun run() { - CommandLine.usage(ProvidedSoftwareCommand(), System.out) - } -} +class ProvidedSoftwareCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommand.kt index b6f2d49d4a..9a9edd18aa 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommand.kt @@ -1,12 +1,10 @@ package ftl.cli.firebase.test.android -import ftl.args.AndroidArgs -import ftl.cli.firebase.test.processValidation import ftl.config.FtlConstants -import ftl.doctor.validateYaml +import ftl.domain.RunDoctorAndroid +import ftl.domain.invoke import picocli.CommandLine.Command import picocli.CommandLine.Option -import java.nio.file.Paths @Command( name = "doctor", @@ -23,19 +21,28 @@ import java.nio.file.Paths ], usageHelpAutoWidth = true ) -class AndroidDoctorCommand : Runnable { - override fun run() { - val ymlPath = Paths.get(configPath) - val validationResult = validateYaml(AndroidArgs, ymlPath) - processValidation(validationResult, fix, ymlPath) - } +class AndroidDoctorCommand : + Runnable, + RunDoctorAndroid { - @Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig - - @Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false - @Option(names = ["-f", "--fix"], description = ["Auto fix flank YAML file"]) - var fix: Boolean = false + @Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig + + @Option( + names = ["-f", "--fix"], + description = ["Auto fix flank YAML file"] + ) + override var fix: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidLocalesCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidLocalesCommand.kt index 0d054c10e7..248197ae9d 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidLocalesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidLocalesCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.android import ftl.cli.firebase.test.android.configuration.AndroidLocalesDescribeCommand import ftl.cli.firebase.test.android.configuration.AndroidLocalesListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine subcommands = [AndroidLocalesListCommand::class, AndroidLocalesDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidLocalesCommand : Runnable { - override fun run() { - CommandLine.usage(AndroidLocalesCommand(), System.out) - } -} +class AndroidLocalesCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidModelsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidModelsCommand.kt index 8522b9376a..821cac2e0a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidModelsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidModelsCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.android import ftl.cli.firebase.test.android.models.AndroidModelDescribeCommand import ftl.cli.firebase.test.android.models.AndroidModelsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine subcommands = [AndroidModelsListCommand::class, AndroidModelDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidModelsCommand : Runnable { - override fun run() { - CommandLine.usage(AndroidModelsCommand(), System.out) - } -} +class AndroidModelsCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidOrientationsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidOrientationsCommand.kt index 972b0688ab..8d31577b36 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidOrientationsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidOrientationsCommand.kt @@ -1,6 +1,7 @@ package ftl.cli.firebase.test.android import ftl.cli.firebase.test.android.orientations.AndroidOrientationsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -15,8 +16,4 @@ import picocli.CommandLine subcommands = [AndroidOrientationsListCommand::class], usageHelpAutoWidth = true ) -class AndroidOrientationsCommand : Runnable { - override fun run() { - CommandLine.usage(AndroidOrientationsCommand(), System.out) - } -} +class AndroidOrientationsCommand : PrintHelp 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 08965edd8b..8aa5d40edb 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 @@ -1,32 +1,16 @@ package ftl.cli.firebase.test.android -import flank.common.logLn -import ftl.analytics.sendConfiguration -import ftl.args.AndroidArgs -import ftl.args.setupLogLevel -import ftl.args.validate import ftl.cli.firebase.test.CommonRunCommand import ftl.config.FtlConstants import ftl.config.android.AndroidFlankConfig import ftl.config.android.AndroidGcloudConfig import ftl.config.createConfiguration -import ftl.mock.MockServer -import ftl.reports.output.configure -import ftl.reports.output.log -import ftl.reports.output.outputReport -import ftl.reports.output.toOutputReportConfiguration +import ftl.domain.RunTestAndroid +import ftl.domain.invoke import ftl.run.ANDROID_SHARD_FILE -import ftl.run.dumpShards -import ftl.run.newTestRun -import ftl.util.DEVICE_SYSTEM -import ftl.util.TEST_TYPE -import ftl.util.printVersionInfo -import ftl.util.setCrashReportTag -import kotlinx.coroutines.runBlocking import picocli.CommandLine import picocli.CommandLine.Command import picocli.CommandLine.Option -import java.nio.file.Paths @Command( name = "run", @@ -45,7 +29,10 @@ Configuration is read from flank.yml ], usageHelpAutoWidth = true ) -class AndroidRunCommand : CommonRunCommand(), Runnable { +class AndroidRunCommand : + CommonRunCommand(), + Runnable, + RunTestAndroid { @CommandLine.Mixin private val androidGcloudConfig = AndroidGcloudConfig() @@ -55,42 +42,15 @@ class AndroidRunCommand : CommonRunCommand(), Runnable { override val config by createConfiguration(androidGcloudConfig, androidFlankConfig) - init { - configPath = FtlConstants.defaultAndroidConfig - } - - override fun run() { - printVersionInfo() - - if (dryRun) { - MockServer.start() - } - - AndroidArgs.load(Paths.get(configPath), cli = this).apply { - setupLogLevel() - - outputReport.configure(toOutputReportConfiguration()) - outputReport.log(this) - setCrashReportTag( - DEVICE_SYSTEM to "android", - TEST_TYPE to type?.name.orEmpty() - ) - sendConfiguration() - }.validate().also { args -> - runBlocking { - if (dumpShards) - args.dumpShards() - else { - logLn(args) - args.newTestRun() - } - } - } - } - @Option( names = ["--dump-shards"], description = ["Measures test shards from given test apks and writes them into $ANDROID_SHARD_FILE file instead of executing."] ) - var dumpShards: Boolean = false + override var dumpShards: Boolean = false + + init { + configPath = FtlConstants.defaultAndroidConfig + } + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt index d8cc4d4a4f..cf0aa276e7 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt @@ -1,17 +1,9 @@ package ftl.cli.firebase.test.android -import flank.common.logLn -import ftl.android.AndroidCatalog.devicesCatalogAsTable -import ftl.android.AndroidCatalog.localesAsTable -import ftl.android.AndroidCatalog.supportedOrientationsAsTable -import ftl.android.AndroidCatalog.supportedVersionsAsTable -import ftl.args.AndroidArgs import ftl.config.FtlConstants -import ftl.environment.ipBlocksListAsTable -import ftl.environment.networkConfigurationAsTable -import ftl.environment.providedSoftwareAsTable +import ftl.domain.DescribeAndroidTestEnvironment +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "test-environment", @@ -30,21 +22,22 @@ import java.nio.file.Paths ], usageHelpAutoWidth = true ) -class AndroidTestEnvironmentCommand : Runnable { - override fun run() { - val projectId = AndroidArgs.loadOrDefault(Paths.get(configPath)).project - logLn(devicesCatalogAsTable(projectId)) - logLn(supportedVersionsAsTable(projectId)) - logLn(localesAsTable(projectId)) - logLn(providedSoftwareAsTable()) - logLn(networkConfigurationAsTable()) - logLn(supportedOrientationsAsTable(projectId)) - logLn(ipBlocksListAsTable()) - } +class AndroidTestEnvironmentCommand : + Runnable, + DescribeAndroidTestEnvironment { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidVersionsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidVersionsCommand.kt index 072e2fbd37..52e9a4c40b 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidVersionsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidVersionsCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.android import ftl.cli.firebase.test.android.versions.AndroidVersionsDescribeCommand import ftl.cli.firebase.test.android.versions.AndroidVersionsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine subcommands = [AndroidVersionsListCommand::class, AndroidVersionsDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidVersionsCommand : Runnable { - override fun run() { - CommandLine.usage(AndroidVersionsCommand(), System.out) - } -} +class AndroidVersionsCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesDescribeCommand.kt index 9e6abb60ab..e0e06456a7 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.android.configuration -import flank.common.log -import ftl.android.AndroidCatalog.getLocaleDescription -import ftl.args.AndroidArgs import ftl.config.FtlConstants -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeAndroidLocales +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -18,11 +15,9 @@ import java.nio.file.Paths header = ["Describe a locales "], usageHelpAutoWidth = true ) -class AndroidLocalesDescribeCommand : Runnable { - override fun run() { - if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.") - log(getLocaleDescription(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, locale)) - } +class AndroidLocalesDescribeCommand : + Runnable, + DescribeAndroidLocales { @CommandLine.Parameters( index = "0", @@ -34,8 +29,13 @@ class AndroidLocalesDescribeCommand : Runnable { " using \$ gcloud firebase test android locales list\n." ] ) - var locale: String = "" + override var locale: String = "" - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt index a7f869f754..5723676dd6 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.android.configuration -import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.args.AndroidArgs import ftl.config.FtlConstants +import ftl.domain.ListAndroidLocales +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of Android locales available to test against"], usageHelpAutoWidth = true ) -class AndroidLocalesListCommand : Runnable { - override fun run() { - logLn(AndroidCatalog.localesAsTable(projectId = AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class AndroidLocalesListCommand : + Runnable, + ListAndroidLocales { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt index 3acbacfea9..0be4caa073 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.android.models -import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.args.AndroidArgs import ftl.config.FtlConstants -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeAndroidModels +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -18,18 +15,23 @@ import java.nio.file.Paths header = ["Describe android model "], usageHelpAutoWidth = true ) -class AndroidModelDescribeCommand : Runnable { - override fun run() { - if (modelId.isBlank()) throw FlankConfigurationError("Argument MODEL_ID must be specified.") - logLn(AndroidCatalog.describeModel(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, modelId)) - } +class AndroidModelDescribeCommand : + Runnable, + DescribeAndroidModels { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig - - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath = FtlConstants.defaultAndroidConfig + @CommandLine.Parameters( index = "0", arity = "1", @@ -37,8 +39,10 @@ class AndroidModelDescribeCommand : Runnable { defaultValue = "", description = [ "The models to describe, found" + - " using \$ gcloud firebase test android models list." + " using \$ gcloud firebase test android models list." ] ) - var modelId: String = "" + override var modelId: String = "" + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelsListCommand.kt index 7a9fdd7a0d..2e2446a074 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.android.models -import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.args.AndroidArgs import ftl.config.FtlConstants +import ftl.domain.ListAndroidModels +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of Android devices available to test against"], usageHelpAutoWidth = true ) -class AndroidModelsListCommand : Runnable { - override fun run() { - logLn(AndroidCatalog.devicesCatalogAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class AndroidModelsListCommand : + Runnable, + ListAndroidModels { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt index 7cf2c53947..81b4d2e49a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.android.orientations -import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.args.AndroidArgs import ftl.config.FtlConstants +import ftl.domain.ListAndroidOrientations +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of Android orientations available to test against"], usageHelpAutoWidth = true ) -class AndroidOrientationsListCommand : Runnable { - override fun run() { - logLn(AndroidCatalog.supportedOrientationsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class AndroidOrientationsListCommand : + Runnable, + ListAndroidOrientations { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt index c37c56838a..ed95dbbbee 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.android.versions -import flank.common.logLn -import ftl.android.AndroidCatalog -import ftl.args.AndroidArgs import ftl.config.FtlConstants -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeAndroidVersions +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -19,14 +16,15 @@ import java.nio.file.Paths description = ["Print current list of android versions available to test against"], usageHelpAutoWidth = true ) -class AndroidVersionsDescribeCommand : Runnable { - override fun run() { - if (versionId.isBlank()) throw FlankConfigurationError("Argument VERSION_ID must be specified.") - logLn(AndroidCatalog.describeSoftwareVersion(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, versionId)) - } +class AndroidVersionsDescribeCommand : + Runnable, + DescribeAndroidVersions { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig @CommandLine.Parameters( index = "0", @@ -38,5 +36,7 @@ class AndroidVersionsDescribeCommand : Runnable { " using \$ gcloud firebase test android versions list." ] ) - var versionId: String = "" + override var versionId: String = "" + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt index a64dfbb1a8..0dfdb36d9f 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.android.versions -import flank.common.logLn -import ftl.android.AndroidCatalog.supportedVersionsAsTable -import ftl.args.AndroidArgs import ftl.config.FtlConstants +import ftl.domain.ListAndroidVersions +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of Android OS versions available to test against"], usageHelpAutoWidth = true ) -class AndroidVersionsListCommand : Runnable { - override fun run() { - logLn(supportedVersionsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class AndroidVersionsListCommand : + Runnable, + ListAndroidVersions { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultAndroidConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommand.kt index 7063ff546d..c6e7d265c1 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommand.kt @@ -1,12 +1,10 @@ package ftl.cli.firebase.test.ios -import ftl.args.IosArgs -import ftl.cli.firebase.test.processValidation import ftl.config.FtlConstants -import ftl.doctor.validateYaml +import ftl.domain.RunDoctorIos +import ftl.domain.invoke import picocli.CommandLine.Command import picocli.CommandLine.Option -import java.nio.file.Paths @Command( name = "doctor", @@ -23,19 +21,28 @@ import java.nio.file.Paths ], usageHelpAutoWidth = true ) -class IosDoctorCommand : Runnable { - override fun run() { - val ymlPath = Paths.get(configPath) - val validationResult = validateYaml(IosArgs, Paths.get(configPath)) - processValidation(validationResult, fix, ymlPath) - } +class IosDoctorCommand : + Runnable, + RunDoctorIos { - @Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig - - @Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false - @Option(names = ["-f", "--fix"], description = ["Auto fix flank YAML file"]) - var fix: Boolean = false + @Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig + + @Option( + names = ["-f", "--fix"], + description = ["Auto fix flank YAML file"] + ) + override var fix: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosLocalesCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosLocalesCommand.kt index 121949ef01..4c9e89a6f7 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosLocalesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosLocalesCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios import ftl.cli.firebase.test.ios.configuration.IosLocalesDescribeCommand import ftl.cli.firebase.test.ios.configuration.IosLocalesListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine subcommands = [IosLocalesListCommand::class, IosLocalesDescribeCommand::class], usageHelpAutoWidth = true ) -class IosLocalesCommand : Runnable { - override fun run() { - CommandLine.usage(IosLocalesCommand(), System.out) - } -} +class IosLocalesCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosModelsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosModelsCommand.kt index 06982fb4f3..7bba6d6d79 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosModelsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosModelsCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios import ftl.cli.firebase.test.ios.models.IosModelDescribeCommand import ftl.cli.firebase.test.ios.models.IosModelsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine subcommands = [IosModelsListCommand::class, IosModelDescribeCommand::class], usageHelpAutoWidth = true ) -class IosModelsCommand : Runnable { - override fun run() { - CommandLine.usage(IosModelsCommand(), System.out) - } -} +class IosModelsCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosOrientationsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosOrientationsCommand.kt index 50db970935..8b64d2e228 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosOrientationsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosOrientationsCommand.kt @@ -1,6 +1,7 @@ package ftl.cli.firebase.test.ios import ftl.cli.firebase.test.ios.orientations.IosOrientationsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -15,8 +16,4 @@ import picocli.CommandLine subcommands = [IosOrientationsListCommand::class], usageHelpAutoWidth = true ) -class IosOrientationsCommand : Runnable { - override fun run() { - CommandLine.usage(IosOrientationsCommand(), System.out) - } -} +class IosOrientationsCommand : PrintHelp 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 85c7c70f93..41080d901a 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 @@ -1,32 +1,16 @@ package ftl.cli.firebase.test.ios -import flank.common.logLn -import ftl.analytics.sendConfiguration -import ftl.args.IosArgs -import ftl.args.setupLogLevel -import ftl.args.validate import ftl.cli.firebase.test.CommonRunCommand import ftl.config.FtlConstants import ftl.config.createConfiguration import ftl.config.ios.IosFlankConfig import ftl.config.ios.IosGcloudConfig -import ftl.mock.MockServer -import ftl.reports.output.configure -import ftl.reports.output.log -import ftl.reports.output.outputReport -import ftl.reports.output.toOutputReportConfiguration +import ftl.domain.RunIosTest +import ftl.domain.invoke import ftl.run.IOS_SHARD_FILE -import ftl.run.dumpShards -import ftl.run.newTestRun -import ftl.util.DEVICE_SYSTEM -import ftl.util.TEST_TYPE -import ftl.util.printVersionInfo -import ftl.util.setCrashReportTag -import kotlinx.coroutines.runBlocking import picocli.CommandLine import picocli.CommandLine.Command import picocli.CommandLine.Option -import java.nio.file.Paths @Command( name = "run", @@ -45,7 +29,10 @@ Configuration is read from flank.yml ], usageHelpAutoWidth = true ) -class IosRunCommand : CommonRunCommand(), Runnable { +class IosRunCommand : + CommonRunCommand(), + Runnable, + RunIosTest { @CommandLine.Mixin private val iosGcloudConfig = IosGcloudConfig() @@ -55,36 +42,15 @@ class IosRunCommand : CommonRunCommand(), Runnable { override val config by createConfiguration(iosGcloudConfig, iosFlankConfig) - init { - configPath = FtlConstants.defaultIosConfig - } - - override fun run() { - printVersionInfo() - - if (dryRun) { - MockServer.start() - } - - IosArgs.load(Paths.get(configPath), cli = this).apply { - setupLogLevel() - outputReport.configure(toOutputReportConfiguration()) - outputReport.log(this) - setCrashReportTag( - DEVICE_SYSTEM to "ios", - TEST_TYPE to type?.name.orEmpty() - ) - sendConfiguration() - if (dumpShards.not()) logLn(this) - }.validate().run { - if (dumpShards) dumpShards() - else runBlocking { newTestRun() } - } - } - @Option( names = ["--dump-shards"], description = ["Measures test shards from given test apks and writes them into $IOS_SHARD_FILE file instead of executing."] ) - var dumpShards: Boolean = false + override var dumpShards: Boolean = false + + init { + configPath = FtlConstants.defaultIosConfig + } + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt index 8c05cf4f9a..5624cb814c 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt @@ -1,17 +1,9 @@ package ftl.cli.firebase.test.ios -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.environment.ipBlocksListAsTable -import ftl.environment.networkConfigurationAsTable -import ftl.environment.providedSoftwareAsTable -import ftl.ios.IosCatalog.devicesCatalogAsTable -import ftl.ios.IosCatalog.localesAsTable -import ftl.ios.IosCatalog.softwareVersionsAsTable -import ftl.ios.IosCatalog.supportedOrientationsAsTable +import ftl.domain.DescribeIosTestEnvironment +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "test-environment", @@ -30,21 +22,22 @@ import java.nio.file.Paths ], usageHelpAutoWidth = true ) -class IosTestEnvironmentCommand : Runnable { - override fun run() { - val projectId = IosArgs.loadOrDefault(Paths.get(configPath)).project - logLn(devicesCatalogAsTable(projectId)) - logLn(softwareVersionsAsTable(projectId)) - logLn(localesAsTable(projectId)) - logLn(providedSoftwareAsTable()) - logLn(networkConfigurationAsTable()) - logLn(supportedOrientationsAsTable(projectId)) - logLn(ipBlocksListAsTable()) - } +class IosTestEnvironmentCommand : + Runnable, + DescribeIosTestEnvironment { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosVersionsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosVersionsCommand.kt index d9f7d6f3de..614a425bb0 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosVersionsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosVersionsCommand.kt @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios import ftl.cli.firebase.test.ios.versions.IosVersionsDescribeCommand import ftl.cli.firebase.test.ios.versions.IosVersionsListCommand +import ftl.util.PrintHelp import picocli.CommandLine @CommandLine.Command( @@ -16,8 +17,4 @@ import picocli.CommandLine description = ["Information about available software versions. For example prints list of available software versions"], usageHelpAutoWidth = true ) -class IosVersionsCommand : Runnable { - override fun run() { - CommandLine.usage(IosVersionsCommand(), System.out) - } -} +class IosVersionsCommand : PrintHelp diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt index c915f2b825..c4343726f8 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.ios.configuration -import flank.common.log -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog.getLocaleDescription -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeIosLocales +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -18,11 +15,9 @@ import java.nio.file.Paths header = ["Describe a locales "], usageHelpAutoWidth = true ) -class IosLocalesDescribeCommand : Runnable { - override fun run() { - if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.") - log(getLocaleDescription(IosArgs.loadOrDefault(Paths.get(configPath)).project, locale)) - } +class IosLocalesDescribeCommand : + Runnable, + DescribeIosLocales { @CommandLine.Parameters( index = "0", @@ -34,8 +29,13 @@ class IosLocalesDescribeCommand : Runnable { " using \$ gcloud firebase test ios locales list\n." ] ) - var locale: String = "" + override var locale: String = "" - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt index bc2b70bb2e..55e5a4ba4a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.ios.configuration -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog.localesAsTable +import ftl.domain.ListIosLocales +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of iOS locales available to test against"], usageHelpAutoWidth = true ) -class IosLocalesListCommand : Runnable { - override fun run() { - logLn(localesAsTable(projectId = IosArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class IosLocalesListCommand : + Runnable, + ListIosLocales { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelDescribeCommand.kt index 0e2a2c6da3..6ee0ae887b 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.ios.models -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeIosModels +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -18,17 +15,15 @@ import java.nio.file.Paths header = ["Describe iOS model "], usageHelpAutoWidth = true ) -class IosModelDescribeCommand : Runnable { - override fun run() { - if (modelId.isBlank()) throw FlankConfigurationError("Argument MODEL_ID must be specified.") - logLn(IosCatalog.describeModel(IosArgs.loadOrDefault(Paths.get(configPath)).project, modelId)) - } +class IosModelDescribeCommand : + Runnable, + DescribeIosModels { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig - - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) - var usageHelpRequested: Boolean = false + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig @CommandLine.Parameters( index = "0", @@ -40,5 +35,14 @@ class IosModelDescribeCommand : Runnable { " using \$ gcloud firebase test ios models list." ] ) - var modelId: String = "" + override var modelId: String = "" + + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) + var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommand.kt index 744c11c928..af4a286202 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.ios.models -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog.devicesCatalogAsTable +import ftl.domain.ListIosModels +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of iOS devices available to test against"], usageHelpAutoWidth = true ) -class IosModelsListCommand : Runnable { - override fun run() { - logLn(devicesCatalogAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class IosModelsListCommand : + Runnable, + ListIosModels { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt index 72c3d9b256..335b18a89e 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.ios.orientations -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog +import ftl.domain.ListIosOrientations +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of iOS orientations available to test against"], usageHelpAutoWidth = true ) -class IosOrientationsListCommand : Runnable { - override fun run() { - logLn(IosCatalog.supportedOrientationsAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class IosOrientationsListCommand : + Runnable, + ListIosOrientations { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt index d6687fc13b..b9503c768e 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt @@ -1,12 +1,9 @@ package ftl.cli.firebase.test.ios.versions -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeIosVersions +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "describe", @@ -19,14 +16,15 @@ import java.nio.file.Paths description = ["Print current list of iOS versions available to test against"], usageHelpAutoWidth = true ) -class IosVersionsDescribeCommand : Runnable { - override fun run() { - if (versionId.isBlank()) throw FlankConfigurationError("Argument VERSION_ID must be specified.") - logLn(IosCatalog.describeSoftwareVersion(IosArgs.loadOrDefault(Paths.get(configPath)).project, versionId)) - } +class IosVersionsDescribeCommand : + Runnable, + DescribeIosVersions { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig @CommandLine.Parameters( index = "0", @@ -38,5 +36,7 @@ class IosVersionsDescribeCommand : Runnable { " using \$ gcloud firebase test ios versions list." ] ) - var versionId: String = "" + override var versionId: String = "" + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt index 8d78ff9df0..9a421b099e 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt @@ -1,11 +1,9 @@ package ftl.cli.firebase.test.ios.versions -import flank.common.logLn -import ftl.args.IosArgs import ftl.config.FtlConstants -import ftl.ios.IosCatalog.softwareVersionsAsTable +import ftl.domain.ListIosVersions +import ftl.domain.invoke import picocli.CommandLine -import java.nio.file.Paths @CommandLine.Command( name = "list", @@ -18,14 +16,22 @@ import java.nio.file.Paths description = ["Print current list of iOS versions available to test against"], usageHelpAutoWidth = true ) -class IosVersionsListCommand : Runnable { - override fun run() { - logLn(softwareVersionsAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) - } +class IosVersionsListCommand : + Runnable, + ListIosVersions { - @CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) - var configPath: String = FtlConstants.defaultIosConfig + @CommandLine.Option( + names = ["-c", "--config"], + description = ["YAML config file path"] + ) + override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommand.kt index 75f9327787..af4d570769 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ipblocks/IPBlocksListCommand.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase.test.ipblocks -import flank.common.logLn -import ftl.environment.ipBlocksListAsTable +import ftl.domain.ListIPBlocks +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -15,8 +15,8 @@ import picocli.CommandLine header = ["List all IP address blocks used by Firebase Test Lab devices"], usageHelpAutoWidth = true ) -class IPBlocksListCommand : Runnable { - override fun run() { - logLn(ipBlocksListAsTable()) - } +class IPBlocksListCommand : + Runnable, + ListIPBlocks { + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt index 31ceadf46f..837454424d 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt @@ -1,8 +1,7 @@ package ftl.cli.firebase.test.networkprofiles -import flank.common.logLn -import ftl.environment.networkProfileDescription -import ftl.run.exception.FlankConfigurationError +import ftl.domain.DescribeNetworkProfiles +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -16,11 +15,9 @@ import picocli.CommandLine header = ["Describe a network profile "], usageHelpAutoWidth = true ) -class NetworkProfilesDescribeCommand : Runnable { - override fun run() { - if (profileId.isBlank()) throw FlankConfigurationError("Argument PROFILE_ID must be specified.") - logLn(networkProfileDescription(profileId)) - } +class NetworkProfilesDescribeCommand : + Runnable, + DescribeNetworkProfiles { @CommandLine.Parameters( index = "0", @@ -32,5 +29,7 @@ class NetworkProfilesDescribeCommand : Runnable { " using \$ gcloud beta firebase test network-profiles list." ] ) - var profileId: String = "" + override var profileId: String = "" + + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt index 3674f9d849..1f9520fc44 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase.test.networkprofiles -import flank.common.logLn -import ftl.environment.networkConfigurationAsTable +import ftl.domain.ListNetworkProfiles +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -15,9 +15,8 @@ import picocli.CommandLine header = ["List all network profiles available for testing "], usageHelpAutoWidth = true ) -class NetworkProfilesListCommand : Runnable { - override fun run() { - logLn("fetching available network profiles...") - logLn(networkConfigurationAsTable()) - } +class NetworkProfilesListCommand : + Runnable, + ListNetworkProfiles { + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt index 2556bebab6..3a3aaffac1 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt @@ -1,7 +1,7 @@ package ftl.cli.firebase.test.providedsoftware -import flank.common.logLn -import ftl.environment.providedSoftwareAsTable +import ftl.domain.ListProvidedSoftware +import ftl.domain.invoke import picocli.CommandLine @CommandLine.Command( @@ -15,8 +15,8 @@ import picocli.CommandLine header = ["The software environment provided by TestExecutionService."], usageHelpAutoWidth = true ) -class ProvidedSoftwareListCommand : Runnable { - override fun run() { - logLn(providedSoftwareAsTable()) - } +class ProvidedSoftwareListCommand : + Runnable, + ListProvidedSoftware { + override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/domain/CancelLastRun.kt b/test_runner/src/main/kotlin/ftl/domain/CancelLastRun.kt new file mode 100644 index 0000000000..112f22ea5c --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/CancelLastRun.kt @@ -0,0 +1,10 @@ +package ftl.domain + +import ftl.args.AndroidArgs +import ftl.run.cancelLastRun + +interface CancelLastRun + +fun CancelLastRun.invoke() { + cancelLastRun(AndroidArgs.default()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt new file mode 100644 index 0000000000..265bc7b488 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.log +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeAndroidLocales { + val locale: String + val configPath: String +} + +fun DescribeAndroidLocales.invoke() { + if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.") + log(AndroidCatalog.getLocaleDescription(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, locale)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt new file mode 100644 index 0000000000..ddfbb04a06 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidModels.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeAndroidModels { + val configPath: String + val modelId: String +} + +operator fun DescribeAndroidModels.invoke() { + if (modelId.isBlank()) throw FlankConfigurationError("Argument MODEL_ID must be specified.") + logLn(AndroidCatalog.describeModel(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, modelId)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt new file mode 100644 index 0000000000..9effcb100a --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidTestEnvironment.kt @@ -0,0 +1,24 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import ftl.environment.ipBlocksListAsTable +import ftl.environment.networkConfigurationAsTable +import ftl.environment.providedSoftwareAsTable +import java.nio.file.Paths + +interface DescribeAndroidTestEnvironment { + val configPath: String +} + +fun DescribeAndroidTestEnvironment.invoke() { + val projectId = AndroidArgs.loadOrDefault(Paths.get(configPath)).project + logLn(AndroidCatalog.devicesCatalogAsTable(projectId)) + logLn(AndroidCatalog.supportedVersionsAsTable(projectId)) + logLn(AndroidCatalog.localesAsTable(projectId)) + logLn(providedSoftwareAsTable()) + logLn(networkConfigurationAsTable()) + logLn(AndroidCatalog.supportedOrientationsAsTable(projectId)) + logLn(ipBlocksListAsTable()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt new file mode 100644 index 0000000000..3324c73268 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeAndroidVersions.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeAndroidVersions { + val versionId: String + val configPath: String +} + +fun DescribeAndroidVersions.invoke() { + if (versionId.isBlank()) throw FlankConfigurationError("Argument VERSION_ID must be specified.") + logLn(AndroidCatalog.describeSoftwareVersion(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, versionId)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt new file mode 100644 index 0000000000..4f41b44a5b --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.log +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeIosLocales { + val locale: String + val configPath: String +} + +fun DescribeIosLocales.invoke() { + if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.") + log(IosCatalog.getLocaleDescription(IosArgs.loadOrDefault(Paths.get(configPath)).project, locale)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosModels.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosModels.kt new file mode 100644 index 0000000000..bab257a44b --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosModels.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeIosModels { + val modelId: String + val configPath: String +} + +operator fun DescribeIosModels.invoke() { + if (modelId.isBlank()) throw FlankConfigurationError("Argument MODEL_ID must be specified.") + logLn(IosCatalog.describeModel(IosArgs.loadOrDefault(Paths.get(configPath)).project, modelId)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt new file mode 100644 index 0000000000..c6abf64a0d --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosTestEnvironment.kt @@ -0,0 +1,24 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.environment.ipBlocksListAsTable +import ftl.environment.networkConfigurationAsTable +import ftl.environment.providedSoftwareAsTable +import ftl.ios.IosCatalog +import java.nio.file.Paths + +interface DescribeIosTestEnvironment { + val configPath: String +} + +operator fun DescribeIosTestEnvironment.invoke() { + val projectId = IosArgs.loadOrDefault(Paths.get(configPath)).project + logLn(IosCatalog.devicesCatalogAsTable(projectId)) + logLn(IosCatalog.softwareVersionsAsTable(projectId)) + logLn(IosCatalog.localesAsTable(projectId)) + logLn(providedSoftwareAsTable()) + logLn(networkConfigurationAsTable()) + logLn(IosCatalog.supportedOrientationsAsTable(projectId)) + logLn(ipBlocksListAsTable()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosVersions.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosVersions.kt new file mode 100644 index 0000000000..6e79752ce4 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosVersions.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import ftl.run.exception.FlankConfigurationError +import java.nio.file.Paths + +interface DescribeIosVersions { + val configPath: String + val versionId: String +} + +operator fun DescribeIosVersions.invoke() { + if (versionId.isBlank()) throw FlankConfigurationError("Argument VERSION_ID must be specified.") + logLn(IosCatalog.describeSoftwareVersion(IosArgs.loadOrDefault(Paths.get(configPath)).project, versionId)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeNetworkProfiles.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeNetworkProfiles.kt new file mode 100644 index 0000000000..d4656ac868 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeNetworkProfiles.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.environment.networkProfileDescription +import ftl.run.exception.FlankConfigurationError + +interface DescribeNetworkProfiles { + val profileId: String +} + +operator fun DescribeNetworkProfiles.invoke() { + if (profileId.isBlank()) throw FlankConfigurationError("Argument PROFILE_ID must be specified.") + logLn(networkProfileDescription(profileId)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt new file mode 100644 index 0000000000..7dce3479ea --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import java.nio.file.Paths + +interface ListAndroidLocales { + val configPath: String +} + +operator fun ListAndroidLocales.invoke() { + logLn(AndroidCatalog.localesAsTable(projectId = AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt new file mode 100644 index 0000000000..b3a1f1fa13 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidModels.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import java.nio.file.Paths + +interface ListAndroidModels { + val configPath: String +} + +operator fun ListAndroidModels.invoke() { + logLn(AndroidCatalog.devicesCatalogAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt new file mode 100644 index 0000000000..11e83bc167 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidOrientations.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import java.nio.file.Paths + +interface ListAndroidOrientations { + val configPath: String +} + +operator fun ListAndroidOrientations.invoke() { + logLn(AndroidCatalog.supportedOrientationsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt b/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt new file mode 100644 index 0000000000..0bfb3219c0 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListAndroidVersions.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.android.AndroidCatalog +import ftl.args.AndroidArgs +import java.nio.file.Paths + +interface ListAndroidVersions { + val configPath: String +} + +operator fun ListAndroidVersions.invoke() { + logLn(AndroidCatalog.supportedVersionsAsTable(AndroidArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIPBlocks.kt b/test_runner/src/main/kotlin/ftl/domain/ListIPBlocks.kt new file mode 100644 index 0000000000..3ea4e84553 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListIPBlocks.kt @@ -0,0 +1,10 @@ +package ftl.domain + +import flank.common.logLn +import ftl.environment.ipBlocksListAsTable + +interface ListIPBlocks + +operator fun ListIPBlocks.invoke() { + logLn(ipBlocksListAsTable()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIosLocales.kt b/test_runner/src/main/kotlin/ftl/domain/ListIosLocales.kt new file mode 100644 index 0000000000..516d70b5f2 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListIosLocales.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import java.nio.file.Paths + +interface ListIosLocales { + val configPath: String +} + +operator fun ListIosLocales.invoke() { + logLn(IosCatalog.localesAsTable(projectId = IosArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIosModels.kt b/test_runner/src/main/kotlin/ftl/domain/ListIosModels.kt new file mode 100644 index 0000000000..7acc038122 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListIosModels.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import java.nio.file.Paths + +interface ListIosModels { + val configPath: String +} + +operator fun ListIosModels.invoke() { + logLn(IosCatalog.devicesCatalogAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt b/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt new file mode 100644 index 0000000000..bb657594da --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListIosOrientations.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import java.nio.file.Paths + +interface ListIosOrientations { + var configPath: String +} + +operator fun ListIosOrientations.invoke() { + logLn(IosCatalog.supportedOrientationsAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListIosVersions.kt b/test_runner/src/main/kotlin/ftl/domain/ListIosVersions.kt new file mode 100644 index 0000000000..189ed45cf2 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListIosVersions.kt @@ -0,0 +1,14 @@ +package ftl.domain + +import flank.common.logLn +import ftl.args.IosArgs +import ftl.ios.IosCatalog +import java.nio.file.Paths + +interface ListIosVersions { + var configPath: String +} + +operator fun ListIosVersions.invoke() { + logLn(IosCatalog.softwareVersionsAsTable(IosArgs.loadOrDefault(Paths.get(configPath)).project)) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListNetworkProfiles.kt b/test_runner/src/main/kotlin/ftl/domain/ListNetworkProfiles.kt new file mode 100644 index 0000000000..8ca0a0d809 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListNetworkProfiles.kt @@ -0,0 +1,11 @@ +package ftl.domain + +import flank.common.logLn +import ftl.environment.networkConfigurationAsTable + +interface ListNetworkProfiles + +operator fun ListNetworkProfiles.invoke() { + logLn("fetching available network profiles...") + logLn(networkConfigurationAsTable()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt b/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt new file mode 100644 index 0000000000..53e81c90c3 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/ListProvidedSoftware.kt @@ -0,0 +1,10 @@ +package ftl.domain + +import flank.common.logLn +import ftl.environment.providedSoftwareAsTable + +interface ListProvidedSoftware + +operator fun ListProvidedSoftware.invoke() { + logLn(providedSoftwareAsTable()) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/LoginGoogleAccount.kt b/test_runner/src/main/kotlin/ftl/domain/LoginGoogleAccount.kt new file mode 100644 index 0000000000..4075fb07df --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/LoginGoogleAccount.kt @@ -0,0 +1,9 @@ +package ftl.domain + +import ftl.gc.UserAuth + +interface LoginGoogleAccount + +operator fun LoginGoogleAccount.invoke() { + UserAuth().request() +} diff --git a/test_runner/src/main/kotlin/ftl/domain/RefreshLastRun.kt b/test_runner/src/main/kotlin/ftl/domain/RefreshLastRun.kt new file mode 100644 index 0000000000..8558c50f1b --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/RefreshLastRun.kt @@ -0,0 +1,13 @@ +package ftl.domain + +import ftl.args.AndroidArgs +import ftl.run.refreshLastRun + +interface RefreshLastRun + +suspend operator fun RefreshLastRun.invoke() { + refreshLastRun( + currentArgs = AndroidArgs.default(), + testShardChunks = emptyList() + ) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/RunDoctorAndroid.kt b/test_runner/src/main/kotlin/ftl/domain/RunDoctorAndroid.kt new file mode 100644 index 0000000000..931a983a1e --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/RunDoctorAndroid.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import ftl.args.AndroidArgs +import ftl.cli.firebase.test.processValidation +import ftl.doctor.validateYaml +import java.nio.file.Paths + +interface RunDoctorAndroid { + val configPath: String + val fix: Boolean +} + +operator fun RunDoctorAndroid.invoke() { + val ymlPath = Paths.get(configPath) + val validationResult = validateYaml(AndroidArgs, ymlPath) + processValidation(validationResult, fix, ymlPath) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/RunDoctorIos.kt b/test_runner/src/main/kotlin/ftl/domain/RunDoctorIos.kt new file mode 100644 index 0000000000..836c7cc0b6 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/RunDoctorIos.kt @@ -0,0 +1,17 @@ +package ftl.domain + +import ftl.args.IosArgs +import ftl.cli.firebase.test.processValidation +import ftl.doctor.validateYaml +import java.nio.file.Paths + +interface RunDoctorIos { + val configPath: String + val fix: Boolean +} + +operator fun RunDoctorIos.invoke() { + val ymlPath = Paths.get(configPath) + val validationResult = validateYaml(IosArgs, Paths.get(configPath)) + processValidation(validationResult, fix, ymlPath) +} diff --git a/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt b/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt new file mode 100644 index 0000000000..4e5adb5721 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt @@ -0,0 +1,63 @@ +package ftl.domain + +import flank.common.logLn +import ftl.analytics.sendConfiguration +import ftl.args.createAndroidArgs +import ftl.args.setupLogLevel +import ftl.args.validate +import ftl.config.AndroidConfig +import ftl.config.defaultAndroidConfig +import ftl.config.loadAndroidConfig +import ftl.config.plus +import ftl.mock.MockServer +import ftl.reports.output.configure +import ftl.reports.output.log +import ftl.reports.output.outputReport +import ftl.reports.output.toOutputReportConfiguration +import ftl.run.dumpShards +import ftl.run.newTestRun +import ftl.util.* +import kotlinx.coroutines.runBlocking +import java.nio.file.Paths + +interface RunTestAndroid { + val configPath: String + val config: AndroidConfig + val dryRun: Boolean + val obfuscate: Boolean + val dumpShards: Boolean +} + +operator fun RunTestAndroid.invoke() { + printVersionInfo() + + if (dryRun) { + MockServer.start() + } + + createAndroidArgs( + config = defaultAndroidConfig() + + loadAndroidConfig(reader = loadFile(Paths.get(configPath))) + + config, + obfuscate = obfuscate + ).apply { + setupLogLevel() + + outputReport.configure(toOutputReportConfiguration()) + outputReport.log(this) + setCrashReportTag( + DEVICE_SYSTEM to "android", + TEST_TYPE to type?.name.orEmpty() + ) + sendConfiguration() + }.validate().also { args -> + runBlocking { + if (dumpShards) + args.dumpShards() + else { + logLn(args) + args.newTestRun() + } + } + } +} diff --git a/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt b/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt new file mode 100644 index 0000000000..a979bd21c8 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt @@ -0,0 +1,52 @@ +package ftl.domain + +import flank.common.logLn +import ftl.analytics.sendConfiguration +import ftl.args.* +import ftl.config.* +import ftl.mock.MockServer +import ftl.reports.output.configure +import ftl.reports.output.log +import ftl.reports.output.outputReport +import ftl.reports.output.toOutputReportConfiguration +import ftl.run.dumpShards +import ftl.run.newTestRun +import ftl.util.* +import kotlinx.coroutines.runBlocking +import java.nio.file.Paths + +interface RunIosTest { + val configPath: String + val config: IosConfig + val dryRun: Boolean + val obfuscate: Boolean + val dumpShards: Boolean +} + +operator fun RunIosTest.invoke() { + printVersionInfo() + + if (dryRun) { + MockServer.start() + } + + createIosArgs( + config = defaultIosConfig() + + loadIosConfig(reader = loadFile(Paths.get(configPath))) + + config, + obfuscate = obfuscate + ).apply { + setupLogLevel() + outputReport.configure(toOutputReportConfiguration()) + outputReport.log(this) + setCrashReportTag( + DEVICE_SYSTEM to "ios", + TEST_TYPE to type?.name.orEmpty() + ) + sendConfiguration() + if (dumpShards.not()) logLn(this) + }.validate().run { + if (dumpShards) dumpShards() + else runBlocking { newTestRun() } + } +} diff --git a/test_runner/src/main/kotlin/ftl/util/CliCommand.kt b/test_runner/src/main/kotlin/ftl/util/CliCommand.kt new file mode 100644 index 0000000000..bc4f1b02a0 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/util/CliCommand.kt @@ -0,0 +1,9 @@ +package ftl.util + +import picocli.CommandLine + +interface PrintHelp : Runnable { + override fun run() { + CommandLine.usage(this, System.out) + } +} From 2ec65b58f500e0695e70b6f9111cad29e3cc17d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20G=C3=B3ral?= Date: Mon, 22 Mar 2021 16:28:27 +0100 Subject: [PATCH 2/4] Fix lint errors --- .../kotlin/ftl/cli/firebase/CancelCommand.kt | 6 +++++- .../kotlin/ftl/cli/firebase/TestCommand.kt | 6 +++++- .../ftl/cli/firebase/test/AndroidCommand.kt | 8 +++++++- .../ftl/cli/firebase/test/IosCommand.kt | 8 +++++++- .../models/AndroidModelDescribeCommand.kt | 2 +- .../main/kotlin/ftl/domain/RunTestAndroid.kt | 10 +++++++--- .../src/main/kotlin/ftl/domain/RunTestIos.kt | 19 ++++++++++++++----- 7 files changed, 46 insertions(+), 13 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt index a9daddf605..2bdbd98b69 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/CancelCommand.kt @@ -24,7 +24,11 @@ class CancelCommand : Runnable, CancelLastRun { - @CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) var usageHelpRequested: Boolean = false override fun run() = invoke() diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt index 80edc91628..f6ecfa2b67 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt @@ -1,6 +1,10 @@ package ftl.cli.firebase -import ftl.cli.firebase.test.* +import ftl.cli.firebase.test.AndroidCommand +import ftl.cli.firebase.test.IPBlocksCommand +import ftl.cli.firebase.test.IosCommand +import ftl.cli.firebase.test.NetworkProfilesCommand +import ftl.cli.firebase.test.ProvidedSoftwareCommand import ftl.util.PrintHelp import picocli.CommandLine.Command diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt index bd5daa6c8e..fd2d3ed9d7 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/AndroidCommand.kt @@ -1,6 +1,12 @@ package ftl.cli.firebase.test -import ftl.cli.firebase.test.android.* +import ftl.cli.firebase.test.android.AndroidDoctorCommand +import ftl.cli.firebase.test.android.AndroidLocalesCommand +import ftl.cli.firebase.test.android.AndroidModelsCommand +import ftl.cli.firebase.test.android.AndroidOrientationsCommand +import ftl.cli.firebase.test.android.AndroidRunCommand +import ftl.cli.firebase.test.android.AndroidTestEnvironmentCommand +import ftl.cli.firebase.test.android.AndroidVersionsCommand import ftl.util.PrintHelp import picocli.CommandLine.Command diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt index 4e414e36d1..8309540c5a 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt @@ -1,6 +1,12 @@ package ftl.cli.firebase.test -import ftl.cli.firebase.test.ios.* +import ftl.cli.firebase.test.ios.IosDoctorCommand +import ftl.cli.firebase.test.ios.IosLocalesCommand +import ftl.cli.firebase.test.ios.IosModelsCommand +import ftl.cli.firebase.test.ios.IosOrientationsCommand +import ftl.cli.firebase.test.ios.IosRunCommand +import ftl.cli.firebase.test.ios.IosTestEnvironmentCommand +import ftl.cli.firebase.test.ios.IosVersionsCommand import ftl.util.PrintHelp import picocli.CommandLine.Command diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt index 0be4caa073..96b908745e 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt @@ -39,7 +39,7 @@ class AndroidModelDescribeCommand : defaultValue = "", description = [ "The models to describe, found" + - " using \$ gcloud firebase test android models list." + " using \$ gcloud firebase test android models list." ] ) override var modelId: String = "" diff --git a/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt b/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt index 4e5adb5721..5822dfe3e0 100644 --- a/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt +++ b/test_runner/src/main/kotlin/ftl/domain/RunTestAndroid.kt @@ -16,7 +16,11 @@ import ftl.reports.output.outputReport import ftl.reports.output.toOutputReportConfiguration import ftl.run.dumpShards import ftl.run.newTestRun -import ftl.util.* +import ftl.util.DEVICE_SYSTEM +import ftl.util.TEST_TYPE +import ftl.util.loadFile +import ftl.util.printVersionInfo +import ftl.util.setCrashReportTag import kotlinx.coroutines.runBlocking import java.nio.file.Paths @@ -37,8 +41,8 @@ operator fun RunTestAndroid.invoke() { createAndroidArgs( config = defaultAndroidConfig() + - loadAndroidConfig(reader = loadFile(Paths.get(configPath))) + - config, + loadAndroidConfig(reader = loadFile(Paths.get(configPath))) + + config, obfuscate = obfuscate ).apply { setupLogLevel() diff --git a/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt b/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt index a979bd21c8..b45b988367 100644 --- a/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt +++ b/test_runner/src/main/kotlin/ftl/domain/RunTestIos.kt @@ -2,8 +2,13 @@ package ftl.domain import flank.common.logLn import ftl.analytics.sendConfiguration -import ftl.args.* -import ftl.config.* +import ftl.args.createIosArgs +import ftl.args.setupLogLevel +import ftl.args.validate +import ftl.config.IosConfig +import ftl.config.defaultIosConfig +import ftl.config.loadIosConfig +import ftl.config.plus import ftl.mock.MockServer import ftl.reports.output.configure import ftl.reports.output.log @@ -11,7 +16,11 @@ import ftl.reports.output.outputReport import ftl.reports.output.toOutputReportConfiguration import ftl.run.dumpShards import ftl.run.newTestRun -import ftl.util.* +import ftl.util.DEVICE_SYSTEM +import ftl.util.TEST_TYPE +import ftl.util.loadFile +import ftl.util.printVersionInfo +import ftl.util.setCrashReportTag import kotlinx.coroutines.runBlocking import java.nio.file.Paths @@ -32,8 +41,8 @@ operator fun RunIosTest.invoke() { createIosArgs( config = defaultIosConfig() + - loadIosConfig(reader = loadFile(Paths.get(configPath))) + - config, + loadIosConfig(reader = loadFile(Paths.get(configPath))) + + config, obfuscate = obfuscate ).apply { setupLogLevel() From f430ef0aa7d63269549a5ce651851c72bcab0713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20G=C3=B3ral?= Date: Mon, 22 Mar 2021 16:49:56 +0100 Subject: [PATCH 3/4] Fix tests --- .../src/main/kotlin/ftl/reports/util/ReportManager.kt | 7 ++++++- .../src/main/kotlin/ftl/run/exception/FlankException.kt | 4 ++-- .../cli/firebase/test/android/AndroidDoctorCommandTest.kt | 2 -- .../ftl/cli/firebase/test/ios/IosDoctorCommandTest.kt | 2 -- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt index 3240507f3e..a571f55760 100644 --- a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt +++ b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt @@ -24,6 +24,7 @@ import ftl.reports.xml.model.JUnitTestResult import ftl.reports.xml.model.getSkippedJUnitTestSuite import ftl.reports.xml.parseAllSuitesXml import ftl.reports.xml.parseOneSuiteXml +import ftl.run.exception.FlankGeneralError import ftl.shard.createTestMethodDurationMap import ftl.util.Artifacts import ftl.util.resolveLocalRunPath @@ -63,7 +64,11 @@ object ReportManager { var mergedXml: JUnitTestResult? = null findXmlFiles(matrices, args).forEach { xmlFile -> - val parsedXml = process(xmlFile) + val parsedXml = try { + process(xmlFile) + } catch (e: Throwable) { + throw FlankGeneralError("Cannot process xml file: ${xmlFile.absolutePath}", e) + } val webLink = getWebLink(matrices, xmlFile) val deviceName = getDeviceString(xmlFile.parentFile.name) diff --git a/test_runner/src/main/kotlin/ftl/run/exception/FlankException.kt b/test_runner/src/main/kotlin/ftl/run/exception/FlankException.kt index 17c1f5a92f..c9adf6bbdb 100644 --- a/test_runner/src/main/kotlin/ftl/run/exception/FlankException.kt +++ b/test_runner/src/main/kotlin/ftl/run/exception/FlankException.kt @@ -67,8 +67,8 @@ class FlankConfigurationError : FlankException { */ class FlankGeneralError : FlankException { constructor(message: String) : super(message) - constructor(cause: Exception) : super(cause = cause) - constructor(message: String, cause: Exception) : super(message, cause) + constructor(cause: Throwable) : super(cause = cause) + constructor(message: String, cause: Throwable) : super(message, cause) } /** diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommandTest.kt index 18a660904e..c0d7990776 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/android/AndroidDoctorCommandTest.kt @@ -37,8 +37,6 @@ class AndroidDoctorCommandTest { "\n" + "\n" + "Options:\n" + - " -c, --config=\n" + - " YAML config file path\n" + " -h, --help Prints this help message\n" ) diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommandTest.kt index 1522aa804d..b7d5d1154a 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/IosDoctorCommandTest.kt @@ -37,8 +37,6 @@ class IosDoctorCommandTest { "\n" + "\n" + "Options:\n" + - " -c, --config=\n" + - " YAML config file path\n" + " -h, --help Prints this help message\n" ) From 2ba06c03361540e7b8c06c2159996fbb7bb6b17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20G=C3=B3ral?= Date: Mon, 22 Mar 2021 17:01:02 +0100 Subject: [PATCH 4/4] Make CommonRunCommand implement Runnable --- .../src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt | 2 +- .../kotlin/ftl/cli/firebase/test/android/AndroidRunCommand.kt | 1 - .../src/main/kotlin/ftl/cli/firebase/test/ios/IosRunCommand.kt | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt index d7e6513880..18f9c784d3 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/CommonRunCommand.kt @@ -8,7 +8,7 @@ import ftl.config.common.CommonGcloudConfig import ftl.config.common.addDevice import picocli.CommandLine -abstract class CommonRunCommand { +abstract class CommonRunCommand : Runnable { @CommandLine.Mixin private val commonGcloudConfig = CommonGcloudConfig() 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 8aa5d40edb..0c6a7a1e31 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 @@ -31,7 +31,6 @@ Configuration is read from flank.yml ) class AndroidRunCommand : CommonRunCommand(), - Runnable, RunTestAndroid { @CommandLine.Mixin 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 41080d901a..8ef65171cf 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 @@ -31,7 +31,6 @@ Configuration is read from flank.yml ) class IosRunCommand : CommonRunCommand(), - Runnable, RunIosTest { @CommandLine.Mixin