Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 committed Jul 22, 2024
1 parent 7dd60fa commit a92473a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions test/test-manager/src/tests/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/test-manager/src/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion test/test-manager/src/vm/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ fn ssh_send_file<R: Read>(
fn ssh_exec(session: &Session, command: &str) -> Result<String> {
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()?;
Expand All @@ -228,7 +229,9 @@ fn ssh_exec(session: &Session, command: &str) -> Result<String> {
.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}");
}

Expand Down

0 comments on commit a92473a

Please sign in to comment.