From db0ea43e758efe574f5628943cbe6c647a23a4ae Mon Sep 17 00:00:00 2001 From: Evgenii Matsiuk Date: Wed, 10 Jul 2024 09:17:15 +0300 Subject: [PATCH] feat(ios): test timeout args were added (#48) feat(ios): test timeout args were added --- src/api.rs | 12 ++++++++++++ src/cli/android/mod.rs | 6 +++++- src/cli/ios/mod.rs | 28 ++++++++++++++++++++++++++++ src/cli/mod.rs | 17 +++++++++++++++++ src/errors.rs | 4 ++-- src/interactor.rs | 4 ++++ 6 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/api.rs b/src/api.rs index 24fd82a..b6d73a6 100644 --- a/src/api.rs +++ b/src/api.rs @@ -50,6 +50,8 @@ pub trait RapiClient { test_env_args: Option>, pull_file_config: Option, concurrency_limit: Option, + test_timeout_default: Option, + test_timeout_max: Option, ) -> Result; async fn get_run(&self, id: &str) -> Result; @@ -140,6 +142,8 @@ impl RapiClient for RapiReqwestClient { test_env_args: Option>, pull_file_config: Option, concurrency_limit: Option, + test_timeout_default: Option, + test_timeout_max: Option, ) -> Result { let url = format!("{}/run", self.base_url); let params = [("api_key", self.api_key.clone())]; @@ -346,6 +350,14 @@ impl RapiClient for RapiReqwestClient { form = form.text("concurrency_limit", concurrency_limit.to_string()) } + if let Some(test_timeout_default) = test_timeout_default { + form = form.text("test_timeout_default", test_timeout_default.to_string()) + } + + if let Some(test_timeout_max) = test_timeout_max { + form = form.text("test_timeout_max", test_timeout_max.to_string()) + } + let response = self.client.post(url).multipart(form).send().await?; let response = api_error_adapter(response) .await? diff --git a/src/cli/android/mod.rs b/src/cli/android/mod.rs index 8acd585..65b42d8 100644 --- a/src/cli/android/mod.rs +++ b/src/cli/android/mod.rs @@ -140,7 +140,9 @@ pub(crate) async fn run( if let Some(limit) = common.concurrency_limit { if limit == 0 { - return Err(InputError::NonPositiveConcurrencyLimit)?; + return Err(InputError::NonPositiveValue { + arg: "--concurrency-limit".to_owned(), + })?; } } @@ -180,6 +182,8 @@ pub(crate) async fn run( None, pull_file_config, common.concurrency_limit, + None, + None, ) .await } diff --git a/src/cli/ios/mod.rs b/src/cli/ios/mod.rs index e7acfaa..ef66f76 100644 --- a/src/cli/ios/mod.rs +++ b/src/cli/ios/mod.rs @@ -187,6 +187,8 @@ pub(crate) async fn run( xctestplan_target_name: Option, retry_args: super::RetryArgs, analytics_args: super::AnalyticsArgs, + test_timeout_default: Option, + test_timeout_max: Option, ) -> Result { let supported_configs = get_supported_configs(); let (device, xcode_version, os_version) = @@ -235,6 +237,30 @@ If you provide any single or two of these parameters, the others will be inferre let retry_args = cli::validate::retry_args(retry_args); cli::validate::result_file_args(&common.result_file_args)?; + if let Some(limit) = common.concurrency_limit { + if limit == 0 { + return Err(InputError::NonPositiveValue { + arg: "--concurrency-limit".to_owned(), + })?; + } + } + + if let Some(limit) = test_timeout_default { + if limit == 0 { + return Err(InputError::NonPositiveValue { + arg: "--test-timeout-default".to_owned(), + })?; + } + } + + if let Some(limit) = test_timeout_max { + if limit == 0 { + return Err(InputError::NonPositiveValue { + arg: "--test-timeout-max".to_owned(), + })?; + } + } + let present_wait: bool = match common.wait { None => true, Some(true) => true, @@ -271,6 +297,8 @@ If you provide any single or two of these parameters, the others will be inferre xctestrun_test_env, None, common.concurrency_limit, + test_timeout_default, + test_timeout_max, ) .await } diff --git a/src/cli/mod.rs b/src/cli/mod.rs index a35e081..484b53e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -85,6 +85,8 @@ impl Cli { xctestplan_target_name, retry_args, analytics_args, + test_timeout_default, + test_timeout_max, } => { ios::run( application, @@ -100,6 +102,8 @@ impl Cli { xctestplan_target_name, retry_args, analytics_args, + test_timeout_default, + test_timeout_max, ) .await } @@ -487,5 +491,18 @@ Note: Files with the same name and path from different devices may overwrite eac #[arg(long, help = "Target name to use for test filtering in .xctestplan")] xctestplan_target_name: Option, + + #[arg( + long, + default_value = "600", + help = "Default timeout for each test in seconds" + )] + test_timeout_default: Option, + + #[arg( + long, + help = "Maximum test timeout in seconds, overriding all other test timeout settings" + )] + test_timeout_max: Option, }, } diff --git a/src/errors.rs b/src/errors.rs index 896145a..d19ac6f 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -82,8 +82,8 @@ pub enum InputError { supported: String, }, - #[error("--concurrency-limit arg should be a positive number")] - NonPositiveConcurrencyLimit, + #[error("{arg} arg should be a positive number")] + NonPositiveValue { arg: String }, } #[derive(Error, Debug)] diff --git a/src/interactor.rs b/src/interactor.rs index cefdb08..a53b982 100644 --- a/src/interactor.rs +++ b/src/interactor.rs @@ -127,6 +127,8 @@ impl TriggerTestRunInteractor { test_env_args: Option>, pull_file_config: Option, concurrency_limit: Option, + test_timeout_default: Option, + test_timeout_max: Option, ) -> Result { let client = RapiReqwestClient::new(base_url, api_key); let steps = match (wait, output) { @@ -163,6 +165,8 @@ impl TriggerTestRunInteractor { test_env_args, pull_file_config, concurrency_limit, + test_timeout_default, + test_timeout_max, ) .await?;