diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test-manager/src/summary.rs | 6 | ||||
| -rw-r--r-- | test/test-manager/src/tests/mod.rs | 37 | ||||
| -rw-r--r-- | test/test-manager/src/tests/test_metadata.rs | 6 |
3 files changed, 29 insertions, 20 deletions
diff --git a/test/test-manager/src/summary.rs b/test/test-manager/src/summary.rs index 55d290ec5a..29a2f8d974 100644 --- a/test/test-manager/src/summary.rs +++ b/test/test-manager/src/summary.rs @@ -5,6 +5,8 @@ use tokio::{ io::{AsyncBufReadExt, AsyncWriteExt}, }; +use crate::tests::should_run_on_os; + #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Failed to open log file {1:?}")] @@ -118,7 +120,7 @@ pub struct Summary { impl Summary { /// Read test summary from `path`. pub async fn parse_log<P: AsRef<Path>>( - all_tests: &[crate::tests::TestMetadata], + all_tests: &[crate::tests::TestDesciption], path: P, ) -> Result<Summary, Error> { let file = fs::OpenOptions::new() @@ -155,7 +157,7 @@ impl Summary { for test in all_tests { // Add missing test results let entry = results.entry(test.name.to_owned()); - if test.should_run_on_os(os) { + if should_run_on_os(test.targets, os) { entry.or_insert(TestResult::Unknown); } else { entry.or_insert(TestResult::Skip); diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs index f50742c042..e3b485972a 100644 --- a/test/test-manager/src/tests/mod.rs +++ b/test/test-manager/src/tests/mod.rs @@ -15,6 +15,7 @@ mod tunnel; mod tunnel_state; mod ui; +use itertools::Itertools; pub use test_metadata::TestMetadata; use anyhow::Context; @@ -29,7 +30,7 @@ use config::TEST_CONFIG; use helpers::{get_app_env, install_app}; pub use install::test_upgrade_app; use mullvad_management_interface::MullvadProxyClient; -use test_rpc::{mullvad_daemon::MullvadClientVersion, ServiceClient}; +use test_rpc::{meta::Os, ServiceClient}; const WAIT_FOR_TUNNEL_STATE_TIMEOUT: Duration = Duration::from_secs(40); @@ -75,20 +76,32 @@ pub enum Error { Other(String), } +#[derive(Clone)] +/// An abbriviated version of [`TestMetadata`] +pub struct TestDesciption { + pub name: &'static str, + pub targets: &'static [Os], + pub priority: Option<i32>, +} + +pub fn should_run_on_os(targets: &[Os], os: Os) -> bool { + targets.is_empty() || targets.contains(&os) +} + /// Get a list of all tests, sorted by priority. -pub fn get_tests() -> Vec<TestMetadata> { - let mut tests: Vec<_> = inventory::iter::<TestMetadata>().cloned().collect(); - tests.sort_by_key(|test| test.priority.unwrap_or(0)); - let test_upgrade_app = TestMetadata { +pub fn get_tests() -> Vec<TestDesciption> { + let tests: Vec<_> = inventory::iter::<TestMetadata>() + .map(|test| TestDesciption { + priority: test.priority, + name: test.name, + targets: test.targets, + }) + .sorted_by_key(|test| test.priority) + .collect_vec(); + let test_upgrade_app = TestDesciption { priority: None, name: "test_upgrade_app", targets: &[], - mullvad_client_version: MullvadClientVersion::None, - func: |_, _, _| { - Box::pin(async { - unreachable!("`test_upgrade_app` should not be executed from this function pointer") - }) - }, }; [vec![test_upgrade_app], tests].concat() } @@ -114,7 +127,7 @@ pub fn get_filtered_tests(specified_tests: &[String]) -> Result<Vec<TestMetadata }) .collect::<Result<_, anyhow::Error>>()? }; - tests.retain(|test| test.should_run_on_os(TEST_CONFIG.os)); + tests.retain(|test| should_run_on_os(test.targets, TEST_CONFIG.os)); Ok(tests) } diff --git a/test/test-manager/src/tests/test_metadata.rs b/test/test-manager/src/tests/test_metadata.rs index 341562acae..79c7f74def 100644 --- a/test/test-manager/src/tests/test_metadata.rs +++ b/test/test-manager/src/tests/test_metadata.rs @@ -10,11 +10,5 @@ pub struct TestMetadata { pub priority: Option<i32>, } -impl TestMetadata { - pub fn should_run_on_os(&self, os: Os) -> bool { - self.targets.is_empty() || self.targets.contains(&os) - } -} - // Register our test metadata struct with inventory to allow submitting tests of this type. inventory::collect!(TestMetadata); |
