Skip to content

Commit

Permalink
Add $HOME/.config/build-wrap/allow.txt test
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Dec 14, 2024
1 parent 0e1f8ff commit 1ef3555
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/integration/config_allow.rs
Original file line number Diff line number Diff line change
@@ -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_DIR");
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"));
}
}
1 change: 1 addition & 0 deletions tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1ef3555

Please sign in to comment.