Add failing test for #346

This fails locally as expected, but I want to confirm that it fails on
CI too.
add_libdifftastic
Wilfred Hughes 2022-09-01 09:40:18 +07:00
parent b31e3c78c1
commit 46bbe06d75
2 changed files with 6 additions and 4 deletions

@ -10,6 +10,8 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.57.0 - uses: dtolnay/rust-toolchain@1.57.0
- run: cargo test - run: cargo test
- name: Run tests when stdout is not a tty
run: cargo test | cat
test_linux_latest_stable: test_linux_latest_stable:
name: Test Linux (latest stable Rust) name: Test Linux (latest stable Rust)

@ -287,7 +287,7 @@ pub fn parse_args() -> Mode {
.parse::<usize>() .parse::<usize>()
.expect("Already validated by clap") .expect("Already validated by clap")
} else { } else {
detect_display_width() detect_display_width().unwrap_or(80)
}; };
let display_mode = if let Some(display_mode_str) = matches.value_of("display") { 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 /// Choose the display width: try to autodetect, or fall back to a
/// sensible default. /// sensible default.
fn detect_display_width() -> usize { fn detect_display_width() -> Option<usize> {
terminal_size::terminal_size().map_or(80, |(w, _)| w.0 as usize) terminal_size::terminal_size().map(|(w, _)| w.0 as usize)
} }
pub fn should_use_color(color_output: ColorOutput) -> bool { pub fn should_use_color(color_output: ColorOutput) -> bool {
@ -405,6 +405,6 @@ mod tests {
#[test] #[test]
fn test_detect_display_width() { fn test_detect_display_width() {
// Basic smoke test. // Basic smoke test.
assert!(detect_display_width() > 10); assert!(detect_display_width().is_some());
} }
} }