Skip to content

Commit 0899349

Browse files
authored
feat(ios): add batch-isolation (#84)
* feat(ios): --batch-isolation * chore(deps): update
1 parent 6e022b7 commit 0899349

10 files changed

Lines changed: 52 additions & 92 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ serde = { version = "1.0.209", features = ["derive"] }
2626
serde-enum-str = "0.4.0"
2727
serde_json = "1.0.127"
2828
serde_yaml = "0.9.33"
29-
serde_with = "3.6.0"
30-
simple_logger = "4.3.3"
29+
serde_with = "3.17.0"
30+
simple_logger = "5.2.0"
3131
shellexpand = "3.1.0"
3232
tempfile = "3.9.0"
3333
# Reqwest pulls in dependency on openssl which we replace with rustls, hence disabling default features
@@ -37,7 +37,7 @@ reqwest = { version = "0.13", default-features = false, features = [
3737
"stream",
3838
"rustls",
3939
] }
40-
time = { version = "0.3.36", features = ["serde-well-known"] }
40+
time = { version = "0.3.47", features = ["serde-well-known"] }
4141
tokio = { version = "1.40.0", features = ["full"] }
4242
tokio-util = "0.7.11"
4343
futures = "0.3"

src/api.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tokio::io;
1818

1919
use crate::{
2020
bundle::{ApplicationBundleReference, LibraryBundleReference},
21-
cli::model::LocalFileReference,
21+
cli::model::{BatchIsolation, LocalFileReference},
2222
errors::{ApiError, EnvArgError, InputError},
2323
filtering::model::SparseMarathonfile,
2424
pull::PullFileConfig,
@@ -63,6 +63,7 @@ pub trait RapiClient {
6363
application_bundle: Option<Vec<ApplicationBundleReference>>,
6464
library_bundle: Option<Vec<LibraryBundleReference>>,
6565
granted_permission: Option<Vec<String>>,
66+
batch_isolation: Option<BatchIsolation>,
6667
) -> Result<String>;
6768
async fn get_run(&self, id: &str) -> Result<TestRun>;
6869

@@ -162,6 +163,7 @@ impl RapiClient for RapiReqwestClient {
162163
application_bundle: Option<Vec<ApplicationBundleReference>>,
163164
library_bundle: Option<Vec<LibraryBundleReference>>,
164165
granted_permission: Option<Vec<String>>,
166+
batch_isolation: Option<BatchIsolation>,
165167
) -> Result<String> {
166168
let url = format!("{}/v2/run", self.base_url);
167169
let params = [("api_key", self.api_key.clone())];
@@ -258,6 +260,8 @@ impl RapiClient for RapiReqwestClient {
258260
let env_args_map = vec_to_hashmap(env_args)?;
259261
let test_env_args_map = vec_to_hashmap(test_env_args)?;
260262

263+
let app_uninstall = batch_isolation.map(|x| x == BatchIsolation::UninstallApp);
264+
261265
let create_request = CreateRunRequest {
262266
s3_test_app_path: s3_test_app_path.clone(),
263267
test_app_md5: test_app.clone().map(|s| s.md5),
@@ -294,6 +298,7 @@ impl RapiClient for RapiReqwestClient {
294298
test_env_args: test_env_args_map,
295299
bundles,
296300
granted_permission: granted_permission.clone(),
301+
app_uninstall,
297302
};
298303

299304
let response = self.client.post(url).json(&create_request).send().await?;
@@ -675,6 +680,8 @@ struct CreateRunRequest {
675680
bundles: Option<Vec<CreateRunBundle>>,
676681
#[serde(rename = "granted_permission", default)]
677682
granted_permission: Option<Vec<String>>,
683+
#[serde(rename = "app_uninstall", default)]
684+
app_uninstall: Option<bool>,
678685
}
679686

680687
#[derive(Serialize, Deserialize, Debug)]

src/cli/android/maestro/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub(crate) async fn run(
130130
None,
131131
None,
132132
None,
133+
None,
133134
formatter,
134135
)
135136
.await

src/cli/android/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ If you are interesting in library testing then please use advance mode with --li
283283
application_bundle,
284284
library_bundle,
285285
None,
286+
None,
286287
formatter,
287288
)
288289
.await

src/cli/ios/maestro/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub(crate) async fn run(
157157
None,
158158
None,
159159
None,
160+
None,
160161
formatter,
161162
)
162163
.await

src/cli/ios/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use anyhow::Result;
77
use indicatif::{ProgressBar, ProgressStyle};
88
use std::collections::HashSet;
99

10+
use crate::cli::model::BatchIsolation;
1011
use crate::cli::validate;
1112
use crate::formatter::Formatter;
1213
use crate::{
@@ -218,6 +219,7 @@ pub(crate) async fn run(
218219
test_timeout_default: Option<u32>,
219220
test_timeout_max: Option<u32>,
220221
granted_permission: Option<Vec<String>>,
222+
batch_isolation: Option<BatchIsolation>,
221223
) -> Result<bool> {
222224
let (device, os_version) = match validate_device_configuration(os_version, device).await {
223225
Ok(value) => value,
@@ -380,6 +382,7 @@ pub(crate) async fn run(
380382
None,
381383
None,
382384
granted_permission,
385+
batch_isolation,
383386
formatter,
384387
)
385388
.await

src/cli/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use clap::CommandFactory;
99
use clap::{Args, Parser, Subcommand};
1010
use std::path::PathBuf;
1111

12+
use crate::cli::model::BatchIsolation;
1213
use crate::errors::default_error_handler;
1314
use crate::interactor::{DownloadArtifactsInteractor, GetDeviceCatalogInteractor};
1415

@@ -97,6 +98,7 @@ impl Cli {
9798
test_timeout_default,
9899
test_timeout_max,
99100
granted_permission,
101+
batch_isolation,
100102
} => {
101103
ios::run(
102104
application,
@@ -115,6 +117,7 @@ impl Cli {
115117
test_timeout_default,
116118
test_timeout_max,
117119
granted_permission,
120+
batch_isolation,
118121
)
119122
.await
120123
}
@@ -586,6 +589,13 @@ Example: '--library-bundle apks/library1-debug-androidTest.apk --library-bundle
586589
#[command(flatten)]
587590
analytics_args: AnalyticsArgs,
588591

592+
#[arg(
593+
value_enum,
594+
long,
595+
help = "Batch isolation mode. Use app uninstall if you want to uninstall app between test batches"
596+
)]
597+
batch_isolation: Option<BatchIsolation>,
598+
589599
#[arg(
590600
long,
591601
help = "xctestrun environment variable (EnvironmentVariables item), example FOO=BAR"

src/cli/model.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ pub struct LocalFileReference {
2727
pub path: PathBuf,
2828
pub md5: String,
2929
}
30+
31+
#[derive(Debug, clap::ValueEnum, Clone, PartialEq, Eq)]
32+
pub enum BatchIsolation {
33+
#[clap(name = "default")]
34+
Default,
35+
#[clap(name = "uninstall_app")]
36+
UninstallApp,
37+
}

0 commit comments

Comments
 (0)