1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #7401 from RenjiSann/coverage

Fix coverage files generation
This commit is contained in:
Sylvestre Ledru 2025-04-07 11:10:12 +02:00 committed by GitHub
commit 0b397c469f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 261 additions and 203 deletions

View file

@ -525,14 +525,20 @@ fn test_gnu_e20() {
let scene = TestScenario::new(util_name!());
let env_bin = String::from(uutests::util::get_tests_binary()) + " " + util_name!();
let input = [
String::from("-i"),
String::from(r#"-SA="B\_C=D" "#) + env_bin.escape_default().to_string().as_str() + "",
];
let (input, output) = (
[
String::from("-i"),
String::from(r#"-SA="B\_C=D" "#) + env_bin.escape_default().to_string().as_str() + "",
],
"A=B C=D\n",
);
let mut output = "A=B C=D\n".to_string();
// Workaround for the test to pass when coverage is being run.
// If enabled, the binary called by env_bin will most probably be
// instrumented for coverage, and thus will set the
// __LLVM_PROFILE_RT_INIT_ONCE
if env::var("__LLVM_PROFILE_RT_INIT_ONCE").is_ok() {
output.push_str("__LLVM_PROFILE_RT_INIT_ONCE=__LLVM_PROFILE_RT_INIT_ONCE\n");
}
let out = scene.ucmd().args(&input).succeeds();
assert_eq!(out.stdout_str(), output);

View file

@ -1762,6 +1762,11 @@ impl UCommand {
}
}
// Forward the LLVM_PROFILE_FILE variable to the call, for coverage purposes.
if let Some(ld_preload) = env::var_os("LLVM_PROFILE_FILE") {
command.env("LLVM_PROFILE_FILE", ld_preload);
}
command
.envs(DEFAULT_ENV)
.envs(self.env_vars.iter().cloned());