summaryrefslogtreecommitdiffhomepage
path: root/test/test-manager/src
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim@hulthe.net>2024-03-04 16:46:52 +0100
committerJoakim Hulthe <joakim@hulthe.net>2024-03-20 16:50:15 +0100
commit1badc46007ab3a97b81ae2ef84df546c6435060c (patch)
tree692afc4feb539c2aa8e251008198e1975f003c9c /test/test-manager/src
parentaca51ed386c29ed5b02614139794439e3847321a (diff)
downloadmullvadvpn-1badc46007ab3a97b81ae2ef84df546c6435060c.tar.xz
mullvadvpn-1badc46007ab3a97b81ae2ef84df546c6435060c.zip
Make e2e tests accept anyhow errors
Diffstat (limited to 'test/test-manager/src')
-rw-r--r--test/test-manager/src/logging.rs2
-rw-r--r--test/test-manager/src/run_tests.rs6
-rw-r--r--test/test-manager/src/tests/mod.rs2
-rw-r--r--test/test-manager/src/tests/split_tunnel.rs20
4 files changed, 14 insertions, 16 deletions
diff --git a/test/test-manager/src/logging.rs b/test/test-manager/src/logging.rs
index cd0bd4af28..e85920b1cd 100644
--- a/test/test-manager/src/logging.rs
+++ b/test/test-manager/src/logging.rs
@@ -1,4 +1,4 @@
-use crate::tests::Error;
+use anyhow::Error;
use colored::Colorize;
use std::sync::{Arc, Mutex};
use test_rpc::logging::{LogOutput, Output};
diff --git a/test/test-manager/src/run_tests.rs b/test/test-manager/src/run_tests.rs
index 6af1536562..6b3da37138 100644
--- a/test/test-manager/src/run_tests.rs
+++ b/test/test-manager/src/run_tests.rs
@@ -2,9 +2,7 @@ use crate::summary::{self, maybe_log_test_result};
use crate::tests::{config::TEST_CONFIG, TestContext};
use crate::{
logging::{panic_as_string, TestOutput},
- mullvad_daemon, tests,
- tests::Error,
- vm,
+ mullvad_daemon, tests, vm,
};
use anyhow::{Context, Result};
use futures::FutureExt;
@@ -187,7 +185,7 @@ pub async fn run_test<F, R, MullvadClient>(
) -> TestOutput
where
F: Fn(super::tests::TestContext, ServiceClient, MullvadClient) -> R,
- R: Future<Output = Result<(), Error>>,
+ R: Future<Output = anyhow::Result<()>>,
{
let _flushed = runner_rpc.try_poll_output().await;
diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs
index f14d5238d5..48d75b9e3f 100644
--- a/test/test-manager/src/tests/mod.rs
+++ b/test/test-manager/src/tests/mod.rs
@@ -33,7 +33,7 @@ pub type TestWrapperFunction = fn(
TestContext,
ServiceClient,
Box<dyn std::any::Any + Send>,
-) -> BoxFuture<'static, Result<(), Error>>;
+) -> BoxFuture<'static, anyhow::Result<()>>;
#[derive(thiserror::Error, Debug)]
pub enum Error {
diff --git a/test/test-manager/src/tests/split_tunnel.rs b/test/test-manager/src/tests/split_tunnel.rs
index 26ccd7794f..4cd48cdce3 100644
--- a/test/test-manager/src/tests/split_tunnel.rs
+++ b/test/test-manager/src/tests/split_tunnel.rs
@@ -3,7 +3,7 @@ use std::str;
use test_macro::test_function;
use test_rpc::{ExecResult, ServiceClient};
-use super::{helpers, Error, TestContext};
+use super::{helpers, TestContext};
#[test_function]
#[cfg(any(target_os = "linux", target_os = "windows"))]
@@ -11,30 +11,30 @@ pub async fn test_split_tunnel(
_: TestContext,
rpc: ServiceClient,
mut mullvad_client: MullvadProxyClient,
-) -> Result<(), Error> {
+) -> anyhow::Result<()> {
let mut errored = false;
- let parse_am_i_mullvad = |result: ExecResult| -> bool {
+ let parse_am_i_mullvad = |result: ExecResult| {
let stdout = str::from_utf8(&result.stdout).expect("am-i-mullvad output is UTF-8");
- if stdout.contains("You are connected") {
+ Ok(if stdout.contains("You are connected") {
true
} else if stdout.contains("You are not connected") {
false
} else {
- panic!("Unexpected output from `am-i-mullvad`: {stdout}")
- }
+ anyhow::bail!("Unexpected output from `am-i-mullvad`: {stdout}")
+ })
};
helpers::connect_and_wait(&mut mullvad_client).await?;
- let i_am_mullvad = parse_am_i_mullvad(rpc.exec("am-i-mullvad", []).await?);
+ let i_am_mullvad = parse_am_i_mullvad(rpc.exec("am-i-mullvad", []).await?)?;
if !i_am_mullvad {
log::error!("We should be connected, but `am-i-mullvad` reported that it was not connected to Mullvad.");
errored = true;
}
let i_am_mullvad_while_split =
- parse_am_i_mullvad(rpc.exec("mullvad-exclude", ["am-i-mullvad"]).await?);
+ parse_am_i_mullvad(rpc.exec("mullvad-exclude", ["am-i-mullvad"]).await?)?;
if i_am_mullvad_while_split {
log::error!("`mullvad-exclude am-i-mullvad` reported that it was connected to Mullvad.");
log::error!("`am-i-mullvad` does not appear to have been split correctly.");
@@ -43,7 +43,7 @@ pub async fn test_split_tunnel(
helpers::disconnect_and_wait(&mut mullvad_client).await?;
- let i_am_mullvad_while_disconnected = parse_am_i_mullvad(rpc.exec("am-i-mullvad", []).await?);
+ let i_am_mullvad_while_disconnected = parse_am_i_mullvad(rpc.exec("am-i-mullvad", []).await?)?;
if i_am_mullvad_while_disconnected {
log::error!("We should be disconnected, but `am-i-mullvad` reported that it was connected to Mullvad.");
log::error!("Host machine is probably connected to Mullvad. This may affect test results.");
@@ -51,7 +51,7 @@ pub async fn test_split_tunnel(
}
if errored {
- panic!("test_split_tunnel failed, see logs for details.");
+ anyhow::bail!("test_split_tunnel failed, see log output for details.");
}
Ok(())