mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
Merge pull request #4578 from daviddwk/fix-util-unnecessary-boolean-not
util: fix unnecessary boolean not operations
This commit is contained in:
commit
74d8f2fae8
1 changed files with 6 additions and 6 deletions
|
@ -2515,7 +2515,9 @@ pub fn run_ucmd_as_root(
|
||||||
ts: &TestScenario,
|
ts: &TestScenario,
|
||||||
args: &[&str],
|
args: &[&str],
|
||||||
) -> std::result::Result<CmdResult, String> {
|
) -> std::result::Result<CmdResult, String> {
|
||||||
if !is_ci() {
|
if is_ci() {
|
||||||
|
Err(format!("{UUTILS_INFO}: {}", "cannot run inside CI"))
|
||||||
|
} else {
|
||||||
// check if we can run 'sudo'
|
// check if we can run 'sudo'
|
||||||
log_info("run", "sudo -E --non-interactive whoami");
|
log_info("run", "sudo -E --non-interactive whoami");
|
||||||
match Command::new("sudo")
|
match Command::new("sudo")
|
||||||
|
@ -2545,8 +2547,6 @@ pub fn run_ucmd_as_root(
|
||||||
Ok(_output) => Err("\"sudo whoami\" didn't return \"root\"".to_string()),
|
Ok(_output) => Err("\"sudo whoami\" didn't return \"root\"".to_string()),
|
||||||
Err(e) => Err(format!("{UUTILS_WARNING}: {e}")),
|
Err(e) => Err(format!("{UUTILS_WARNING}: {e}")),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Err(format!("{UUTILS_INFO}: {}", "cannot run inside CI"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3000,7 +3000,9 @@ mod tests {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[cfg(feature = "whoami")]
|
#[cfg(feature = "whoami")]
|
||||||
fn test_run_ucmd_as_root() {
|
fn test_run_ucmd_as_root() {
|
||||||
if !is_ci() {
|
if is_ci() {
|
||||||
|
println!("TEST SKIPPED (cannot run inside CI)");
|
||||||
|
} else {
|
||||||
// Skip test if we can't guarantee non-interactive `sudo`, or if we're not "root"
|
// Skip test if we can't guarantee non-interactive `sudo`, or if we're not "root"
|
||||||
if let Ok(output) = Command::new("sudo")
|
if let Ok(output) = Command::new("sudo")
|
||||||
.env("LC_ALL", "C")
|
.env("LC_ALL", "C")
|
||||||
|
@ -3019,8 +3021,6 @@ mod tests {
|
||||||
} else {
|
} else {
|
||||||
println!("TEST SKIPPED (cannot run sudo)");
|
println!("TEST SKIPPED (cannot run sudo)");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
println!("TEST SKIPPED (cannot run inside CI)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue