From 81fbe580fe88d0caec0917bd7707839244206533 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Sat, 14 Dec 2024 11:20:24 -0500 Subject: [PATCH] Add `$HOME/.config/build-wrap/allow.txt` test --- tests/integration/config_allow.rs | 27 +++++++++++++++++++++++++++ tests/integration/main.rs | 1 + 2 files changed, 28 insertions(+) create mode 100644 tests/integration/config_allow.rs diff --git a/tests/integration/config_allow.rs b/tests/integration/config_allow.rs new file mode 100644 index 0000000..aa94c0d --- /dev/null +++ b/tests/integration/config_allow.rs @@ -0,0 +1,27 @@ +use crate::util; +use std::fs::{create_dir_all, write}; + +#[test] +fn config_allow() { + let temp_package = util::temp_package(Some("tests/build_scripts/ping.rs"), []).unwrap(); + + let home = util::tempdir().unwrap(); + let config_build_wrap = home.path().join(".config/build-wrap"); + create_dir_all(&config_build_wrap).unwrap(); + write(config_build_wrap.join("allow.txt"), "temp-package\n").unwrap(); + + for allow in [false, true] { + let mut command = util::build_with_build_wrap(); + command.env_remove("XDG_CONFIG_HOME"); + if allow { + command.env("HOME", home.path()); + } + command.current_dir(&temp_package); + + let output = util::exec_forwarding_output(command, false).unwrap(); + // smoelius: The command should succeed precisely when `HOME` is set. + assert_eq!(allow, output.status.success()); + let stderr = std::str::from_utf8(&output.stderr).unwrap(); + assert!(stderr.contains("command failed")); + } +} diff --git a/tests/integration/main.rs b/tests/integration/main.rs index 9ae1d1a..1d05d00 100644 --- a/tests/integration/main.rs +++ b/tests/integration/main.rs @@ -3,6 +3,7 @@ mod build_scripts; mod build_wrap_cmd_changed; mod cargo_target_dir; mod ci; +mod config_allow; mod custom_build_name; mod dogfood; mod enabled;