Skip to content

Commit

Permalink
feat(ios): test timeout args were added (#48)
Browse files Browse the repository at this point in the history
feat(ios): test timeout args were added
  • Loading branch information
matzuk authored Jul 10, 2024
1 parent 67abd65 commit db0ea43
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub trait RapiClient {
test_env_args: Option<Vec<String>>,
pull_file_config: Option<PullFileConfig>,
concurrency_limit: Option<u32>,
test_timeout_default: Option<u32>,
test_timeout_max: Option<u32>,
) -> Result<String>;
async fn get_run(&self, id: &str) -> Result<TestRun>;

Expand Down Expand Up @@ -140,6 +142,8 @@ impl RapiClient for RapiReqwestClient {
test_env_args: Option<Vec<String>>,
pull_file_config: Option<PullFileConfig>,
concurrency_limit: Option<u32>,
test_timeout_default: Option<u32>,
test_timeout_max: Option<u32>,
) -> Result<String> {
let url = format!("{}/run", self.base_url);
let params = [("api_key", self.api_key.clone())];
Expand Down Expand Up @@ -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?
Expand Down
6 changes: 5 additions & 1 deletion src/cli/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})?;
}
}

Expand Down Expand Up @@ -180,6 +182,8 @@ pub(crate) async fn run(
None,
pull_file_config,
common.concurrency_limit,
None,
None,
)
.await
}
28 changes: 28 additions & 0 deletions src/cli/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ pub(crate) async fn run(
xctestplan_target_name: Option<String>,
retry_args: super::RetryArgs,
analytics_args: super::AnalyticsArgs,
test_timeout_default: Option<u32>,
test_timeout_max: Option<u32>,
) -> Result<bool> {
let supported_configs = get_supported_configs();
let (device, xcode_version, os_version) =
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ impl Cli {
xctestplan_target_name,
retry_args,
analytics_args,
test_timeout_default,
test_timeout_max,
} => {
ios::run(
application,
Expand All @@ -100,6 +102,8 @@ impl Cli {
xctestplan_target_name,
retry_args,
analytics_args,
test_timeout_default,
test_timeout_max,
)
.await
}
Expand Down Expand Up @@ -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<String>,

#[arg(
long,
default_value = "600",
help = "Default timeout for each test in seconds"
)]
test_timeout_default: Option<u32>,

#[arg(
long,
help = "Maximum test timeout in seconds, overriding all other test timeout settings"
)]
test_timeout_max: Option<u32>,
},
}
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions src/interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ impl TriggerTestRunInteractor {
test_env_args: Option<Vec<String>>,
pull_file_config: Option<PullFileConfig>,
concurrency_limit: Option<u32>,
test_timeout_default: Option<u32>,
test_timeout_max: Option<u32>,
) -> Result<bool> {
let client = RapiReqwestClient::new(base_url, api_key);
let steps = match (wait, output) {
Expand Down Expand Up @@ -163,6 +165,8 @@ impl TriggerTestRunInteractor {
test_env_args,
pull_file_config,
concurrency_limit,
test_timeout_default,
test_timeout_max,
)
.await?;

Expand Down

0 comments on commit db0ea43

Please sign in to comment.