Skip to content

Commit

Permalink
Make run_test infallible
Browse files Browse the repository at this point in the history
Running a test should never abort the execution of the remaining tests.
This could happen before if `get_mullvad_app_logs()` failed, which was a
bit surprising.
  • Loading branch information
MarkusPettersson98 committed Oct 13, 2023
1 parent 8f47816 commit 7ba2592
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
31 changes: 19 additions & 12 deletions test/test-manager/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub struct TestOutput {
pub error_messages: Vec<Output>,
pub test_name: &'static str,
pub result: Result<Result<(), Error>, PanicMessage>,
pub log_output: LogOutput,
pub log_output: Option<LogOutput>,
}

impl TestOutput {
Expand Down Expand Up @@ -150,21 +150,28 @@ impl TestOutput {
}

println!("{}", format!("TEST {} HAD LOGS:", self.test_name).red());
match &self.log_output.settings_json {
Ok(settings) => println!("settings.json: {}", settings),
Err(e) => println!("Could not get settings.json: {}", e),
}
match &self.log_output {
Some(log) => {
match &log.settings_json {
Ok(settings) => println!("settings.json: {}", settings),
Err(e) => println!("Could not get settings.json: {}", e),
}

match &self.log_output.log_files {
Ok(log_files) => {
for log in log_files {
match log {
Ok(log) => println!("Log {}:\n{}", log.name.to_str().unwrap(), log.content),
Err(e) => println!("Could not get log: {}", e),
match &log.log_files {
Ok(log_files) => {
for log in log_files {
match log {
Ok(log) => {
println!("Log {}:\n{}", log.name.to_str().unwrap(), log.content)
}
Err(e) => println!("Could not get log: {}", e),
}
}
}
Err(e) => println!("Could not get logs: {}", e),
}
}
Err(e) => println!("Could not get logs: {}", e),
None => println!("Missing logs for {}", self.test_name),
}

println!(
Expand Down
15 changes: 6 additions & 9 deletions test/test-manager/src/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ pub async fn run(
test.name,
test_context.clone(),
)
.await
.context("Failed to run test")?;
.await;

if test.mullvad_client_version == MullvadClientVersion::New {
// Try to reset the daemon state if the test failed OR if the test doesn't explicitly
Expand Down Expand Up @@ -183,7 +182,7 @@ pub async fn run_test<F, R, MullvadClient>(
test: &F,
test_name: &'static str,
test_context: super::tests::TestContext,
) -> Result<TestOutput, Error>
) -> TestOutput
where
F: Fn(super::tests::TestContext, ServiceClient, MullvadClient) -> R,
R: Future<Output = Result<(), Error>>,
Expand Down Expand Up @@ -211,15 +210,13 @@ where
}
}
}
let log_output = runner_rpc
.get_mullvad_app_logs()
.await
.map_err(Error::Rpc)?;

Ok(TestOutput {
let log_output = runner_rpc.get_mullvad_app_logs().await.ok();

TestOutput {
log_output,
test_name,
error_messages: output,
result,
})
}
}

0 comments on commit 7ba2592

Please sign in to comment.