From a92473a91ef6a331432a1a933bd4443b2813c12e Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Mon, 22 Jul 2024 20:02:51 +0200 Subject: [PATCH] Improve error messages --- test/test-manager/src/tests/account.rs | 11 +++++++---- test/test-manager/src/tests/ui.rs | 2 +- test/test-manager/src/vm/provision.rs | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/test-manager/src/tests/account.rs b/test/test-manager/src/tests/account.rs index 2cc7c5a95ecd..c67e1bed190c 100644 --- a/test/test-manager/src/tests/account.rs +++ b/test/test-manager/src/tests/account.rs @@ -97,10 +97,13 @@ pub async fn test_too_many_devices( log::info!("Log in with too many devices"); let login_result = login_with_retries(&mut mullvad_client).await; - assert!(matches!( - login_result, - Err(mullvad_management_interface::Error::TooManyDevices) - )); + assert!( + matches!( + login_result, + Err(mullvad_management_interface::Error::TooManyDevices) + ), + "Expected too many devices error, got {login_result:?}" + ); // Run UI test let ui_result = ui::run_test_env( diff --git a/test/test-manager/src/tests/ui.rs b/test/test-manager/src/tests/ui.rs index f4b9af04f3ee..f2b266a4e653 100644 --- a/test/test-manager/src/tests/ui.rs +++ b/test/test-manager/src/tests/ui.rs @@ -82,7 +82,7 @@ pub async fn run_test_env< let stdout = std::str::from_utf8(&result.stdout).unwrap_or("invalid utf8"); let stderr = std::str::from_utf8(&result.stderr).unwrap_or("invalid utf8"); - log::debug!("UI test failed:\n\nstdout:\n\n{stdout}\n\n{stderr}\n"); + log::error!("UI test failed:\n\nstdout:\n\n{stdout}\n\n{stderr}\n"); } Ok(result) diff --git a/test/test-manager/src/vm/provision.rs b/test/test-manager/src/vm/provision.rs index 62ec6934d4eb..4e540a912679 100644 --- a/test/test-manager/src/vm/provision.rs +++ b/test/test-manager/src/vm/provision.rs @@ -218,6 +218,7 @@ fn ssh_send_file( fn ssh_exec(session: &Session, command: &str) -> Result { let mut channel = session.channel_session()?; channel.exec(command)?; + let mut stderr_handle = channel.stderr(); let mut output = String::new(); channel.read_to_string(&mut output)?; channel.send_eof()?; @@ -228,7 +229,9 @@ fn ssh_exec(session: &Session, command: &str) -> Result { .exit_status() .context("Failed to obtain exit status")?; if exit_status != 0 { - log::error!("command failed: {command}\n{output}"); + let mut stderr = String::new(); + stderr_handle.read_to_string(&mut stderr).unwrap(); + log::error!("Command failed: command: {command}\n\noutput:\n{output}\n\nstderr: {stderr}"); bail!("command failed: {exit_status}"); }