mirror of https://github.com/sharkdp/bat
Merge pull request #1888 from patrickpichler/feature/668/add-systemwide-config
Add systemwide config file supportpull/2302/head
commit
546dcf6a55
@ -1,5 +1,5 @@
|
|||||||
# Make sure that the pager gets executed
|
# Make sure that the pager gets executed
|
||||||
--paging=always
|
--paging=always
|
||||||
|
|
||||||
# Output a dummy message for the integration test.
|
# Output a dummy message for the integration test and system wide config test.
|
||||||
--pager="echo dummy-pager-from-config"
|
--pager="echo dummy-pager-from-config"
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
# Make sure that the pager gets executed
|
||||||
|
--paging=always
|
||||||
|
|
||||||
|
# Output a dummy message for the integration test.
|
||||||
|
--pager="echo dummy-pager-from-system-config"
|
@ -0,0 +1,29 @@
|
|||||||
|
use predicates::{prelude::predicate, str::PredicateStrExt};
|
||||||
|
|
||||||
|
mod utils;
|
||||||
|
use utils::command::bat_with_config;
|
||||||
|
|
||||||
|
// This test is ignored, as it needs a special system wide config put into place.
|
||||||
|
// In order to run this tests, use `cargo test --test system_wide_config -- --ignored`
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn use_systemwide_config() {
|
||||||
|
bat_with_config()
|
||||||
|
.arg("test.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::eq("dummy-pager-from-system-config\n").normalize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// This test is ignored, as it needs a special system wide config put into place
|
||||||
|
// In order to run this tests, use `cargo test --test system_wide_config -- --ignored`
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn config_overrides_system_config() {
|
||||||
|
bat_with_config()
|
||||||
|
.env("BAT_CONFIG_PATH", "bat.conf")
|
||||||
|
.arg("test.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::eq("dummy-pager-from-config\n").normalize());
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
#![allow(unused)] // Because indirectly included by e.g.integration_tests.rs, but not everything inside is used
|
||||||
|
|
||||||
|
use assert_cmd::cargo::CommandCargoExt;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
pub fn bat_raw_command_with_config() -> Command {
|
||||||
|
let mut cmd = Command::cargo_bin("bat").unwrap();
|
||||||
|
cmd.current_dir("tests/examples");
|
||||||
|
cmd.env_remove("BAT_CACHE_PATH");
|
||||||
|
cmd.env_remove("BAT_CONFIG_DIR");
|
||||||
|
cmd.env_remove("BAT_CONFIG_PATH");
|
||||||
|
cmd.env_remove("BAT_OPTS");
|
||||||
|
cmd.env_remove("BAT_PAGER");
|
||||||
|
cmd.env_remove("BAT_STYLE");
|
||||||
|
cmd.env_remove("BAT_TABS");
|
||||||
|
cmd.env_remove("BAT_THEME");
|
||||||
|
cmd.env_remove("COLORTERM");
|
||||||
|
cmd.env_remove("NO_COLOR");
|
||||||
|
cmd.env_remove("PAGER");
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn bat_raw_command() -> Command {
|
||||||
|
let mut cmd = bat_raw_command_with_config();
|
||||||
|
cmd.arg("--no-config");
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn bat_with_config() -> assert_cmd::Command {
|
||||||
|
assert_cmd::Command::from_std(bat_raw_command_with_config())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn bat() -> assert_cmd::Command {
|
||||||
|
assert_cmd::Command::from_std(bat_raw_command())
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
|
pub mod command;
|
||||||
pub mod mocked_pagers;
|
pub mod mocked_pagers;
|
||||||
|
Loading…
Reference in New Issue