1use assert_cmd::Command;
3fn bat_with_config() -> Command {
4 let mut cmd = Command::cargo_bin("bat").unwrap();
5 cmd.current_dir("tests/examples");
6 cmd.env_remove("PAGER");
7 cmd.env_remove("BAT_PAGER");
8 cmd.env_remove("BAT_CONFIG_PATH");
9 cmd.env_remove("BAT_STYLE");
10 cmd.env_remove("BAT_THEME");
11 cmd.env_remove("BAT_TABS");
16 let mut cmd = bat_with_config();
17 cmd.arg("--no-config");
27 .stdout("hello world\n")
34 .write_stdin("foo\nbar\n")
37 .stdout("foo\nbar\n");
47 .stdout("hello world\nhello world\n");
51fn concatenate_stdin() {
56 .write_stdin("stdin\n")
59 .stdout("hello world\nstdin\nhello world\n");
63fn concatenate_empty_first() {
69 .stdout("hello world\n");
73fn concatenate_empty_last() {
79 .stdout("hello world\n");
83fn concatenate_empty_both() {
93fn concatenate_empty_between() {
100 .stdout("hello world\nhello world\n");
104fn concatenate_empty_first_and_last() {
111 .stdout("hello world\n");
115fn concatenate_single_line() {
117 .arg("single-line.txt")
118 .arg("single-line.txt")
121 .stdout("Single LineSingle Line");
125fn concatenate_single_line_empty() {
127 .arg("single-line.txt")
129 .arg("single-line.txt")
132 .stdout("Single LineSingle Line");
138 .arg("multiline.txt")
139 .arg("--style=numbers")
140 .arg("--decorations=always")
143 .stdout(" 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n");
149 .arg("multiline.txt")
150 .arg("--line-range=2:3")
153 .stdout("line 2\nline 3\n");
157fn line_range_first_two() {
159 .arg("multiline.txt")
160 .arg("--line-range=:2")
163 .stdout("line 1\nline 2\n");
167fn line_range_last_3() {
169 .arg("multiline.txt")
170 .arg("--line-range=2:")
173 .stdout("line 2\nline 3\nline 4\n");
177fn line_range_multiple() {
179 .arg("multiline.txt")
180 .arg("--line-range=1:2")
181 .arg("--line-range=4:4")
184 .stdout("line 1\nline 2\nline 4\n");
192 .arg("--style=numbers")
193 .arg("--decorations=always")
211fn tabs_passthrough_wrapped() {
215 .arg("--style=plain")
216 .arg("--decorations=always")
238 .arg("--style=plain")
239 .arg("--decorations=always")
261 .arg("--style=plain")
262 .arg("--decorations=always")
280fn tabs_passthrough() {
284 .arg("--style=plain")
285 .arg("--decorations=always")
307 .arg("--style=plain")
308 .arg("--decorations=always")
330 .arg("--style=plain")
331 .arg("--decorations=always")
349fn fail_non_existing() {
350 bat().arg("non-existing-file").assert().failure();
355 bat().arg("sub_directory").assert().failure();
359fn do_not_exit_directory() {
361 .arg("sub_directory")
364 .stdout("hello world\n")
371 .env("PAGER", "echo pager-output")
372 .arg("--paging=always")
376 .stdout("pager-output\n");
380fn pager_overwrite() {
382 .env("PAGER", "echo other-pager")
383 .env("BAT_PAGER", "echo pager-output")
384 .arg("--paging=always")
388 .stdout("pager-output\n");
394 .env("PAGER", "echo other-pager")
395 .env("BAT_PAGER", "")
396 .arg("--paging=always")
400 .stdout("hello world\n");
404fn config_location_test() {
406 .env("BAT_CONFIG_PATH", "bat.conf")
407 .arg("--config-file")
410 .stdout("bat.conf\n");
414fn config_read_arguments_from_file() {
416 .env("BAT_CONFIG_PATH", "bat.conf")
420 .stdout("dummy-pager-from-config\n");
425 // The output will be converted to UTF-8 with a leading UTF-8 BOM
428 .arg("--decorations=always")
429 .arg("test_UTF-16LE.txt")
432 .stdout(std::str::from_utf8(b"\xEF\xBB\xBFhello world\n").unwrap());
436fn can_print_file_named_cache() {
446fn can_print_file_named_cache_with_additional_argument() {
452 .stdout("test\nhello world\n")
457fn can_print_file_starting_with_cache() {
467fn does_not_print_unwanted_file_named_cache() {
468 bat_with_config().arg("cach").assert().failure();
474 .arg("unicode-wrap.txt")
475 .arg("--style=numbers,snip")
476 .arg("--decorations=always")
477 .arg("--terminal-width=40")
481 " 1 ビタミンA ビタミンD ビタミンE ビ
487 3 고양이 고양이 고양이 고양이 고양이
497 5 1 บวก 2 บวก 3 บวก 4 บวก 5 บวก 6 บวก
498 7 บวก 8 บวก 9 บวก 10 บวก 11 บวก 12
499 บวก 13 บวก 14 บวก 15 บวก 16 บวก 17
502 7 Бельгия Болгария Чехия Дания Герман
503 ия Эстония Ирландия Греция Испания
504 Франция Хорватия Италия Кипр Латвия
505 Литва Люксембург Венгрия Мальта Ни
506 дерланды Австрия Польша Португалия
507 Румыния Словения Словакия Финляндия
508 Швеция Великобритания
516 .arg("multiline.txt")
517 .arg("--style=numbers,snip")
518 .arg("--decorations=always")
519 .arg("--line-range=1:2")
520 .arg("--line-range=4:")
521 .arg("--terminal-width=80")
527 ...─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
534fn empty_file_leads_to_empty_output_with_grid_enabled() {
538 .arg("--decorations=always")
539 .arg("--terminal-width=80")
549 .arg("--decorations=always")
550 .arg("--style=header")
552 .arg("--file-name=foo")
555 .stdout("File: foo\n")
560fn filename_binary() {
563 .arg("--decorations=always")
564 .arg("--style=header")
566 .arg("--file-name=foo")
569 .stdout("File: foo <BINARY>\n")
576 .arg("--decorations=always")
577 .arg("--style=header")
580 .write_stdin("stdin\n")
581 .arg("--file-name=foo")
584 .stdout("File: foo\n")
589fn filename_stdin_binary() {
590 let vec = vec![0; 1];
592 .arg("--decorations=always")
593 .arg("--style=header")
595 .arg("--file-name=foo")
598 .stdout("File: foo <BINARY>\n")
603fn filename_multiple_ok() {
605 .arg("--decorations=always")
606 .arg("--style=header")
609 .arg("--file-name=foo")
610 .arg("single-line.txt")
611 .arg("--file-name=bar")
614 .stdout("File: foo\nFile: bar\n")
619fn filename_multiple_err() {
621 .arg("--decorations=always")
622 .arg("--style=header")
625 .arg("--file-name=foo")
626 .arg("single-line.txt")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list