Skip to content

Commit d5bd432

Browse files
committed
Replace implicit cache folder with --package-folder arg
1 parent 542bdf7 commit d5bd432

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

test/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ cargo run --bin test-manager run-tests debian11 \
116116
--display \
117117
--account 0123456789 \
118118
--current-app <git hash or tag> \
119-
--previous-app 2023.2
119+
--old-app 2023.2
120120
```
121121

122122
## macOS
@@ -142,7 +142,7 @@ cargo run --bin test-manager run-tests macos-ventura \
142142
--display \
143143
--account 0123456789 \
144144
--current-app <git hash or tag> \
145-
--previous-app 2023.2
145+
--old-app 2023.2
146146
```
147147

148148
## Note on `ci-runtests.sh`

test/ci-runtests.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ function run_tests_for_os {
198198
run-tests \
199199
--account "${ACCOUNT_TOKEN:?Error: ACCOUNT_TOKEN not set}" \
200200
--current-app "${cur_filename}" \
201-
--previous-app "${prev_filename}" \
201+
--old-app "${prev_filename}" \
202+
--package-folder "$PACKAGES_DIR" \
202203
--test-report "$SCRIPT_DIR/.ci-logs/${os}_report" \
203204
"$os" 2>&1 | sed "s/${ACCOUNT_TOKEN}/\{ACCOUNT_TOKEN\}/g"
204205
}

test/test-manager/src/main.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,8 @@ enum Commands {
8080
account: String,
8181

8282
/// App package to test. Can be a path to the package, just the package file name, git hash
83-
/// or tag. If the direct path is not given, the package is assumed to be in the cache
84-
/// directory for the host OS, given by the following table:
85-
///
86-
/// |Platform | Value | Example |
87-
/// | ------- | ----------------------------------- | ---------------------------- |
88-
/// | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/alice/.cache |
89-
/// | macOS | `$HOME`/Library/Caches | /Users/Alice/Library/Caches |
90-
/// | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
83+
/// or tag. If the direct path is not given, the package is assumed to be in the directory
84+
/// specified by the `--package-folder` argument.
9185
///
9286
/// # Note
9387
///
@@ -103,7 +97,11 @@ enum Commands {
10397
///
10498
/// The CLI interface must be compatible with the upgrade test.
10599
#[arg(long, short)]
106-
previous_app: Option<String>,
100+
old_app: Option<String>,
101+
102+
/// Folder to search for packages. Defaults to current directory.
103+
#[arg(short, long, value_name = "DIR")]
104+
package_folder: Option<PathBuf>,
107105

108106
/// Only run tests matching substrings
109107
test_filters: Vec<String>,
@@ -227,7 +225,8 @@ async fn main() -> Result<()> {
227225
vnc,
228226
account,
229227
current_app,
230-
previous_app,
228+
old_app,
229+
package_folder,
231230
test_filters,
232231
verbose,
233232
test_report,
@@ -261,9 +260,10 @@ async fn main() -> Result<()> {
261260
None => None,
262261
};
263262

264-
let manifest = package::get_app_manifest(vm_config, current_app, previous_app)
265-
.await
266-
.context("Could not find the specified app packages")?;
263+
let manifest =
264+
package::get_app_manifest(vm_config, current_app, old_app, package_folder)
265+
.await
266+
.context("Could not find the specified app packages")?;
267267

268268
let mut instance = vm::run(&config, &name)
269269
.await

test/test-manager/src/package.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ pub async fn get_app_manifest(
2323
config: &VmConfig,
2424
current_app: String,
2525
previous_app: Option<String>,
26+
package_folder: Option<PathBuf>,
2627
) -> Result<Manifest> {
2728
let package_type = (config.os_type, config.package_type, config.architecture);
2829

29-
let current_app_path = find_app(&current_app, false, package_type).await?;
30+
let current_app_path =
31+
find_app(&current_app, false, package_type, package_folder.as_ref()).await?;
3032
log::info!("Current app: {}", current_app_path.display());
3133

3234
let previous_app_path = if let Some(previous_app) = previous_app {
3335
log::info!("Previous app: {}", previous_app);
34-
Some(find_app(&previous_app, false, package_type).await?)
36+
Some(find_app(&previous_app, false, package_type, package_folder.as_ref()).await?)
3537
} else {
3638
log::warn!("No previous app version specified");
3739
None
@@ -44,7 +46,9 @@ pub async fn get_app_manifest(
4446
.map(|c| c.as_str())
4547
.expect("Could not parse version from package name: {current_app}");
4648

47-
let ui_e2e_tests_path = find_app(capture, true, package_type).await.ok();
49+
let ui_e2e_tests_path = find_app(capture, true, package_type, package_folder.as_ref())
50+
.await
51+
.ok();
4852
if let Some(ui_e2e_tests_path) = &ui_e2e_tests_path {
4953
log::info!("GUI e2e test binary: {}", ui_e2e_tests_path.display());
5054
} else {
@@ -62,6 +66,7 @@ async fn find_app(
6266
app: &str,
6367
e2e_bin: bool,
6468
package_type: (OsType, Option<PackageType>, Option<Architecture>),
69+
package_folder: Option<&PathBuf>,
6570
) -> Result<PathBuf> {
6671
// If it's a path, use that path
6772
let app_path = Path::new(app);
@@ -73,10 +78,8 @@ async fn find_app(
7378
let mut app = app.to_owned();
7479
app.make_ascii_lowercase();
7580

76-
let packages_dir = dirs::cache_dir()
77-
.context("Could not find cache directory")?
78-
.join("mullvad-test")
79-
.join("packages");
81+
let current_dir = std::env::current_dir().expect("Unable to get current directory");
82+
let packages_dir = package_folder.unwrap_or(&current_dir);
8083
fs::create_dir_all(&packages_dir).await?;
8184
let mut dir = fs::read_dir(packages_dir.clone())
8285
.await

0 commit comments

Comments
 (0)