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); } }