mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-02 11:22:30 +01:00
Add test for systemwide config file support
There is now a new stage in the CICD workflow present, which will build `bat` with the `BAT_SYSTEM_CONFIG_PREFIX` set to load the config file from `/tests/examples/system_config/bat/config`, plus a basic set of tests, to ensure the feature is working as expected. By default the tests are set to ignored, as they need special setup before they can be run.
This commit is contained in:
@@ -3,7 +3,6 @@ use predicates::boolean::PredicateBooleanExt;
|
||||
use predicates::{prelude::predicate, str::PredicateStrExt};
|
||||
use serial_test::serial;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::str::from_utf8;
|
||||
use tempfile::tempdir;
|
||||
|
||||
@@ -28,41 +27,14 @@ mod unix {
|
||||
use unix::*;
|
||||
|
||||
mod utils;
|
||||
use utils::command::{bat, bat_with_config};
|
||||
|
||||
#[cfg(unix)]
|
||||
use utils::command::bat_raw_command;
|
||||
use utils::mocked_pagers;
|
||||
|
||||
const EXAMPLES_DIR: &str = "tests/examples";
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
fn bat_raw_command() -> Command {
|
||||
let mut cmd = bat_raw_command_with_config();
|
||||
cmd.arg("--no-config");
|
||||
cmd
|
||||
}
|
||||
|
||||
fn bat_with_config() -> assert_cmd::Command {
|
||||
assert_cmd::Command::from_std(bat_raw_command_with_config())
|
||||
}
|
||||
|
||||
fn bat() -> assert_cmd::Command {
|
||||
assert_cmd::Command::from_std(bat_raw_command())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
bat()
|
||||
|
Reference in New Issue
Block a user