mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-15 02:39:23 +02:00
Merge branch 'master' into dark-light
This commit is contained in:
@ -9,7 +9,6 @@ use tempfile::tempdir;
|
||||
mod unix {
|
||||
pub use std::fs::File;
|
||||
pub use std::io::{self, Write};
|
||||
pub use std::os::unix::io::FromRawFd;
|
||||
pub use std::path::PathBuf;
|
||||
pub use std::process::Stdio;
|
||||
pub use std::thread;
|
||||
@ -295,6 +294,7 @@ fn list_themes_without_colors() {
|
||||
|
||||
bat()
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always") // trick bat into setting `Config::loop_through` to false
|
||||
.arg("--list-themes")
|
||||
.assert()
|
||||
.success()
|
||||
@ -303,6 +303,15 @@ fn list_themes_without_colors() {
|
||||
.stdout(predicate::str::contains(default_light_theme_chunk).normalize());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_themes_to_piped_output() {
|
||||
bat()
|
||||
.arg("--list-themes")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("(default)").not());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
|
||||
fn short_help() {
|
||||
@ -403,8 +412,8 @@ fn no_args_doesnt_break() {
|
||||
// this test exists.
|
||||
|
||||
let OpenptyResult { master, slave } = openpty(None, None).expect("Couldn't open pty.");
|
||||
let mut master = unsafe { File::from_raw_fd(master) };
|
||||
let stdin_file = unsafe { File::from_raw_fd(slave) };
|
||||
let mut master = File::from(master);
|
||||
let stdin_file = File::from(slave);
|
||||
let stdout_file = stdin_file.try_clone().unwrap();
|
||||
let stdin = Stdio::from(stdin_file);
|
||||
let stdout = Stdio::from(stdout_file);
|
||||
@ -1008,6 +1017,31 @@ fn enable_pager_if_pp_flag_comes_before_paging() {
|
||||
.stdout(predicate::eq("pager-output\n").normalize());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paging_does_not_override_simple_plain() {
|
||||
bat()
|
||||
.env("PAGER", "echo pager-output")
|
||||
.arg("--decorations=always")
|
||||
.arg("--plain")
|
||||
.arg("--paging=never")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::eq("hello world\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_plain_does_not_override_paging() {
|
||||
bat()
|
||||
.env("PAGER", "echo pager-output")
|
||||
.arg("--paging=always")
|
||||
.arg("--plain")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::eq("pager-output\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pager_failed_to_parse() {
|
||||
bat()
|
||||
@ -1927,6 +1961,16 @@ fn show_all_with_unicode() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binary_as_text() {
|
||||
bat()
|
||||
.arg("--binary=as-text")
|
||||
.arg("control_characters.txt")
|
||||
.assert()
|
||||
.stdout("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_paging_arg() {
|
||||
bat()
|
||||
|
Reference in New Issue
Block a user