From bad229295042809f14ae652deda704af84489b25 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Fri, 28 Oct 2022 13:34:55 -0400 Subject: [PATCH] Add tests for --theme > BAT_THEME > config --- tests/examples/bat-theme.conf | 1 + tests/integration_tests.rs | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/examples/bat-theme.conf diff --git a/tests/examples/bat-theme.conf b/tests/examples/bat-theme.conf new file mode 100644 index 00000000..c39ad713 --- /dev/null +++ b/tests/examples/bat-theme.conf @@ -0,0 +1 @@ +--theme=TwoDark diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 69a3f5fc..05980591 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1794,6 +1794,64 @@ fn no_wrapping_with_chop_long_lines() { wrapping_test("--chop-long-lines", false); } +#[test] +fn theme_arg_overrides_env() { + bat() + .env("BAT_THEME", "TwoDark") + .arg("--paging=never") + .arg("--color=never") + .arg("--terminal-width=80") + .arg("--wrap=never") + .arg("--decorations=always") + .arg("--theme=ansi") + .arg("--style=plain") + .arg("--highlight-line=1") + .write_stdin("Ansi Underscore Test\nAnother Line") + .assert() + .success() + .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stderr(""); +} + +#[test] +fn theme_arg_overrides_env_withconfig() { + bat_with_config() + .env("BAT_CONFIG_PATH", "bat-theme.conf") + .env("BAT_THEME", "TwoDark") + .arg("--paging=never") + .arg("--color=never") + .arg("--terminal-width=80") + .arg("--wrap=never") + .arg("--decorations=always") + .arg("--theme=ansi") + .arg("--style=plain") + .arg("--highlight-line=1") + .write_stdin("Ansi Underscore Test\nAnother Line") + .assert() + .success() + .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stderr(""); +} + +#[test] +fn theme_env_overrides_config() { + bat_with_config() + .env("BAT_CONFIG_PATH", "bat-theme.conf") + .env("BAT_THEME", "ansi") + .arg("--paging=never") + .arg("--color=never") + .arg("--terminal-width=80") + .arg("--wrap=never") + .arg("--decorations=always") + .arg("--style=plain") + .arg("--highlight-line=1") + .write_stdin("Ansi Underscore Test\nAnother Line") + .assert() + .success() + .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stderr(""); +} + #[test] fn highlighting_is_skipped_on_long_lines() { let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() +