From 7756cb45528fd13778718f9c55280dddce167812 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 24 Sep 2023 13:25:09 -0700 Subject: [PATCH] Fix Windows test error Signed-off-by: John Nunley --- src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3319f2a..318ece9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1323,6 +1323,11 @@ mod test { cmd } + #[cfg(unix)] + const OUTPUT: &[u8] = b"hello\n"; + #[cfg(windows)] + const OUTPUT: &[u8] = b"hello\r\n"; + future::block_on(async { // Thread should not be spawned off the bat. assert!(!is_thread_spawned()); @@ -1338,7 +1343,7 @@ mod test { } .or(async { let output = command().output().await.unwrap(); - assert_eq!(output.stdout, b"hello\n"); + assert_eq!(output.stdout, OUTPUT); }) .await; assert!(!is_thread_spawned()); @@ -1357,7 +1362,7 @@ mod test { }) .or(async { let output = command().output().await.unwrap(); - assert_eq!(output.stdout, b"hello\n"); + assert_eq!(output.stdout, OUTPUT); }) .await; assert!(!is_thread_spawned()); @@ -1372,7 +1377,7 @@ mod test { } .or(async { let output = command().output().await.unwrap(); - assert_eq!(output.stdout, b"hello\n"); + assert_eq!(output.stdout, OUTPUT); }) .await; assert!(!is_thread_spawned()); @@ -1385,7 +1390,7 @@ mod test { // We should now be able to poll the process future independently, it will spawn the // thread. let output = command().output().await.unwrap(); - assert_eq!(output.stdout, b"hello\n"); + assert_eq!(output.stdout, OUTPUT); assert!(is_thread_spawned()); }); }