From df5c787ec7a77f5a1b000c20f484142cf6f6ff12 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 2 Sep 2022 10:47:00 -0700 Subject: [PATCH] Revert "Add failing test for #346" This reverts commit 46bbe06d75874b9f9fb3983661fba18c400b4dfd. --- .github/workflows/test.yml | 2 -- src/options.rs | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6816b9f14..b5c29f3dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,6 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@1.57.0 - run: cargo test - - name: Run tests when stdout is not a tty - run: cargo test | cat test_linux_latest_stable: name: Test Linux (latest stable Rust) diff --git a/src/options.rs b/src/options.rs index b9ea586e7..17cea806f 100644 --- a/src/options.rs +++ b/src/options.rs @@ -287,7 +287,7 @@ pub fn parse_args() -> Mode { .parse::() .expect("Already validated by clap") } else { - detect_display_width().unwrap_or(80) + detect_display_width() }; let display_mode = if let Some(display_mode_str) = matches.value_of("display") { @@ -376,8 +376,8 @@ pub fn parse_args() -> Mode { /// Choose the display width: try to autodetect, or fall back to a /// sensible default. -fn detect_display_width() -> Option { - terminal_size::terminal_size().map(|(w, _)| w.0 as usize) +fn detect_display_width() -> usize { + terminal_size::terminal_size().map_or(80, |(w, _)| w.0 as usize) } pub fn should_use_color(color_output: ColorOutput) -> bool { @@ -405,6 +405,6 @@ mod tests { #[test] fn test_detect_display_width() { // Basic smoke test. - assert!(detect_display_width().is_some()); + assert!(detect_display_width() > 10); } }