summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-04-10 10:32:56 +0200
committerDavid Lönnhager <david.l@mullvad.net>2024-04-10 10:32:56 +0200
commit0a924210fa43c9132e80f35fbbf22483f03a3d1a (patch)
tree283073510a08a1da2d149ed0e58a9d40f1f6505d
parentfc2d3fb4d40b77f22d2b0bd240f2790f82e3eb2b (diff)
parent8f4aa580012e2a3f54415e03900515e39cf3d500 (diff)
downloadmullvadvpn-0a924210fa43c9132e80f35fbbf22483f03a3d1a.tar.xz
mullvadvpn-0a924210fa43c9132e80f35fbbf22483f03a3d1a.zip
Merge branch 'sort-e2e-test-summary'
-rw-r--r--test/test-manager/src/main.rs14
-rw-r--r--test/test-manager/src/run_tests.rs10
-rw-r--r--test/test-manager/src/summary.rs2
-rw-r--r--test/test-manager/src/tests/mod.rs7
4 files changed, 26 insertions, 7 deletions
diff --git a/test/test-manager/src/main.rs b/test/test-manager/src/main.rs
index a708c3fe29..37d7227967 100644
--- a/test/test-manager/src/main.rs
+++ b/test/test-manager/src/main.rs
@@ -59,6 +59,9 @@ enum Commands {
keep_changes: bool,
},
+ /// List all tests and their priority.
+ ListTests,
+
/// Spawn a runner instance and run tests
RunTests {
/// Name of the runner config
@@ -198,6 +201,17 @@ async fn main() -> Result<()> {
Ok(())
}
+ Commands::ListTests => {
+ println!("priority\tname");
+ for test in tests::get_tests() {
+ println!(
+ "{priority:8}\t{name}",
+ name = test.name,
+ priority = test.priority.unwrap_or(0),
+ );
+ }
+ Ok(())
+ }
Commands::RunTests {
name,
display,
diff --git a/test/test-manager/src/run_tests.rs b/test/test-manager/src/run_tests.rs
index 38e5253fe8..0c7868e529 100644
--- a/test/test-manager/src/run_tests.rs
+++ b/test/test-manager/src/run_tests.rs
@@ -2,8 +2,7 @@ use crate::{
logging::{panic_as_string, TestOutput},
mullvad_daemon,
summary::{self, maybe_log_test_result},
- tests,
- tests::{config::TEST_CONFIG, TestContext},
+ tests::{self, config::TEST_CONFIG, get_tests, TestContext},
vm,
};
use anyhow::{Context, Result};
@@ -50,10 +49,9 @@ pub async fn run(
print_os_version(&client).await;
- let mut tests: Vec<_> = inventory::iter::<tests::TestMetadata>()
- .filter(|test| test.should_run_on_os(TEST_CONFIG.os))
- .collect();
- tests.sort_by_key(|test| test.priority.unwrap_or(0));
+ let mut tests = get_tests();
+
+ tests.retain(|test| test.should_run_on_os(TEST_CONFIG.os));
if !test_filters.is_empty() {
tests.retain(|test| {
diff --git a/test/test-manager/src/summary.rs b/test/test-manager/src/summary.rs
index c485ac6397..30b71948cf 100644
--- a/test/test-manager/src/summary.rs
+++ b/test/test-manager/src/summary.rs
@@ -199,7 +199,7 @@ impl Summary {
/// be parsed, we should not abort the entire summarization.
pub async fn print_summary_table<P: AsRef<Path>>(summary_files: &[P]) {
// Collect test details
- let tests: Vec<_> = inventory::iter::<crate::tests::TestMetadata>().collect();
+ let tests = crate::tests::get_tests();
let mut summaries = vec![];
let mut failed_to_parse = vec![];
diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs
index 0ccbb9a0e7..32a32cb44a 100644
--- a/test/test-manager/src/tests/mod.rs
+++ b/test/test-manager/src/tests/mod.rs
@@ -64,6 +64,13 @@ pub enum Error {
Other(String),
}
+/// Get a list of all tests, sorted by priority.
+pub fn get_tests() -> Vec<&'static TestMetadata> {
+ let mut tests: Vec<_> = inventory::iter::<TestMetadata>().collect();
+ tests.sort_by_key(|test| test.priority.unwrap_or(0));
+ tests
+}
+
/// Restore settings to the defaults.
pub async fn cleanup_after_test(mullvad_client: &mut MullvadProxyClient) -> anyhow::Result<()> {
log::debug!("Cleaning up daemon in test cleanup");