mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-26 01:33:44 +01:00
Add integration tests for clircle cycle detection
This commit is contained in:
parent
21ae26cb17
commit
ace655e164
0
tests/examples/cycle.txt
vendored
Normal file
0
tests/examples/cycle.txt
vendored
Normal file
@ -1,11 +1,14 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::assert::OutputAssertExt;
|
||||||
|
use assert_cmd::cargo::CommandCargoExt;
|
||||||
use predicates::{prelude::predicate, str::PredicateStrExt};
|
use predicates::{prelude::predicate, str::PredicateStrExt};
|
||||||
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
|
||||||
const EXAMPLES_DIR: &str = "tests/examples";
|
const EXAMPLES_DIR: &str = "tests/examples";
|
||||||
|
|
||||||
fn bat_with_config() -> Command {
|
fn bat_raw_command() -> Command {
|
||||||
let mut cmd = Command::cargo_bin("bat").unwrap();
|
let mut cmd = Command::cargo_bin("bat").unwrap();
|
||||||
cmd.current_dir("tests/examples");
|
cmd.current_dir("tests/examples");
|
||||||
cmd.env_remove("PAGER");
|
cmd.env_remove("PAGER");
|
||||||
@ -17,7 +20,11 @@ fn bat_with_config() -> Command {
|
|||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bat() -> Command {
|
fn bat_with_config() -> assert_cmd::Command {
|
||||||
|
assert_cmd::Command::from_std(bat_raw_command())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bat() -> assert_cmd::Command {
|
||||||
let mut cmd = bat_with_config();
|
let mut cmd = bat_with_config();
|
||||||
cmd.arg("--no-config");
|
cmd.arg("--no-config");
|
||||||
cmd
|
cmd
|
||||||
@ -189,6 +196,30 @@ fn line_range_multiple() {
|
|||||||
.stdout("line 1\nline 2\nline 4\n");
|
.stdout("line 1\nline 2\nline 4\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn basic_io_cycle() {
|
||||||
|
let file_out = Stdio::from(File::open("tests/examples/cycle.txt").unwrap());
|
||||||
|
bat_raw_command()
|
||||||
|
.arg("test.txt")
|
||||||
|
.arg("cycle.txt")
|
||||||
|
.stdout(file_out)
|
||||||
|
.assert()
|
||||||
|
.failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_to_stdout_cycle() {
|
||||||
|
let file_out = Stdio::from(File::open("tests/examples/cycle.txt").unwrap());
|
||||||
|
let file_in = Stdio::from(File::open("tests/examples/cycle.txt").unwrap());
|
||||||
|
bat_raw_command()
|
||||||
|
.stdin(file_in)
|
||||||
|
.arg("test.txt")
|
||||||
|
.arg("-")
|
||||||
|
.stdout(file_out)
|
||||||
|
.assert()
|
||||||
|
.failure();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tabs_numbers() {
|
fn tabs_numbers() {
|
||||||
bat()
|
bat()
|
||||||
|
Loading…
Reference in New Issue
Block a user