From b204f43aae9dc5c3e8cb162823da95e99484d75d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 14 Jan 2022 13:12:40 +0000 Subject: [PATCH] tests: Fix beta clippy issues error: this boolean expression can be simplified --> tests/integration.rs:3755:33 | 3755 | assert!(!(empty > 5), "No login on pty"); | ^^^^^^^^^^^^ help: try: `empty <= 5` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool error: unneeded late initalization --> tests/integration.rs:7619:13 | 7619 | let mut success; | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::needless-late-init` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init help: declare `success` here | 7621 | let mut success = if let Some(status) = send_migration | +++++++++++++++++ help: remove the assignments from the branches | 7625 ~ status.success() 7626 | } else { 7627 ~ false | help: add a semicolon after the `if` expression | 7628 | }; | + error: unneeded late initalization --> tests/integration.rs:7838:13 | 7838 | let mut success; | ^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init help: declare `success` here | 7840 | let mut success = if let Some(status) = send_migration | +++++++++++++++++ help: remove the assignments from the branches | 7844 ~ status.success() 7845 | } else { 7846 ~ false | help: add a semicolon after the `if` expression | 7847 | }; | + Signed-off-by: Rob Bradford --- tests/integration.rs | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 2c91a4eee..949084af1 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -3752,7 +3752,7 @@ mod parallel { } Err(mpsc::TryRecvError::Empty) => { empty += 1; - assert!(!(empty > 5), "No login on pty"); + assert!(empty <= 5, "No login on pty"); } _ => panic!("No login on pty"), } @@ -7616,31 +7616,33 @@ mod live_migration { .spawn() .unwrap(); - let mut success; // The 'send-migration' command should be executed successfully within the given timeout - if let Some(status) = send_migration + let success = if let Some(status) = send_migration .wait_timeout(std::time::Duration::from_secs(30)) .unwrap() { - success = status.success(); + status.success() } else { - success = false; - } + false + }; + if !success { let _ = send_migration.kill(); let output = send_migration.wait_with_output().unwrap(); eprintln!("\n\n==== Start 'send_migration' output ====\n\n---stdout---\n{}\n\n---stderr---\n{}\n\n==== End 'send_migration' output ====\n\n", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr)); } + // The 'receive-migration' command should be executed successfully within the given timeout - if let Some(status) = receive_migration + let success = if let Some(status) = receive_migration .wait_timeout(std::time::Duration::from_secs(30)) .unwrap() { - success = status.success(); + status.success() } else { - success = false; - } + false + }; + if !success { let _ = receive_migration.kill(); let output = receive_migration.wait_with_output().unwrap(); @@ -7835,31 +7837,33 @@ mod live_migration { .spawn() .unwrap(); - let mut success; // The 'send-migration' command should be executed successfully within the given timeout - if let Some(status) = send_migration + let success = if let Some(status) = send_migration .wait_timeout(std::time::Duration::from_secs(30)) .unwrap() { - success = status.success(); + status.success() } else { - success = false; - } + false + }; + if !success { let _ = send_migration.kill(); let output = send_migration.wait_with_output().unwrap(); eprintln!("\n\n==== Start 'send_migration' output ====\n\n---stdout---\n{}\n\n---stderr---\n{}\n\n==== End 'send_migration' output ====\n\n", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr)); } + // The 'receive-migration' command should be executed successfully within the given timeout - if let Some(status) = receive_migration + let success = if let Some(status) = receive_migration .wait_timeout(std::time::Duration::from_secs(30)) .unwrap() { - success = status.success(); + status.success() } else { - success = false; - } + false + }; + if !success { let _ = receive_migration.kill(); let output = receive_migration.wait_with_output().unwrap();