mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #4043 from sylvestre/clippy
Fix some clippy warnings
This commit is contained in:
commit
28127a433e
32 changed files with 122 additions and 126 deletions
|
@ -27,7 +27,7 @@ const USAGE: &str = "\
|
|||
|
||||
fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<(Option<u32>, Option<u32>, IfFrom)> {
|
||||
let dest_gid = if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
|
||||
fs::metadata(&file)
|
||||
fs::metadata(file)
|
||||
.map(|meta| Some(meta.gid()))
|
||||
.map_err_context(|| format!("failed to get attributes of {}", file.quote()))?
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult<(Option<u32>, Optio
|
|||
let dest_uid: Option<u32>;
|
||||
let dest_gid: Option<u32>;
|
||||
if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
|
||||
let meta = fs::metadata(&file)
|
||||
let meta = fs::metadata(file)
|
||||
.map_err_context(|| format!("failed to get attributes of {}", file.quote()))?;
|
||||
dest_gid = Some(meta.gid());
|
||||
dest_uid = Some(meta.uid());
|
||||
|
|
|
@ -124,7 +124,7 @@ fn open_file(name: &str) -> io::Result<LineReader> {
|
|||
match name {
|
||||
"-" => Ok(LineReader::Stdin(stdin())),
|
||||
_ => {
|
||||
let f = File::open(&Path::new(name))?;
|
||||
let f = File::open(Path::new(name))?;
|
||||
Ok(LineReader::FileIn(BufReader::new(f)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1115,7 +1115,7 @@ fn copy_directory(
|
|||
.follow_links(options.dereference)
|
||||
{
|
||||
let p = or_continue!(path);
|
||||
let path = current_dir.join(&p.path());
|
||||
let path = current_dir.join(p.path());
|
||||
|
||||
let local_to_root_parent = match root_parent {
|
||||
Some(parent) => {
|
||||
|
@ -1131,7 +1131,7 @@ fn copy_directory(
|
|||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
or_continue!(path.strip_prefix(&parent)).to_path_buf()
|
||||
or_continue!(path.strip_prefix(parent)).to_path_buf()
|
||||
}
|
||||
}
|
||||
None => path.clone(),
|
||||
|
@ -1351,7 +1351,7 @@ fn context_for(src: &Path, dest: &Path) -> String {
|
|||
/// Implements a simple backup copy for the destination file.
|
||||
/// TODO: for the backup, should this function be replaced by `copy_file(...)`?
|
||||
fn backup_dest(dest: &Path, backup_path: &Path) -> CopyResult<PathBuf> {
|
||||
fs::copy(dest, &backup_path)?;
|
||||
fs::copy(dest, backup_path)?;
|
||||
Ok(backup_path.into())
|
||||
}
|
||||
|
||||
|
@ -1566,7 +1566,7 @@ fn copy_file(
|
|||
.write(true)
|
||||
.truncate(false)
|
||||
.create(true)
|
||||
.open(&dest)
|
||||
.open(dest)
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
|
@ -1630,7 +1630,7 @@ fn copy_helper(
|
|||
fn copy_fifo(dest: &Path, overwrite: OverwriteMode) -> CopyResult<()> {
|
||||
if dest.exists() {
|
||||
overwrite.verify(dest)?;
|
||||
fs::remove_file(&dest)?;
|
||||
fs::remove_file(dest)?;
|
||||
}
|
||||
|
||||
let name = CString::new(dest.as_os_str().as_bytes()).unwrap();
|
||||
|
@ -1647,7 +1647,7 @@ fn copy_link(
|
|||
symlinked_files: &mut HashSet<FileInformation>,
|
||||
) -> CopyResult<()> {
|
||||
// Here, we will copy the symlink itself (actually, just recreate it)
|
||||
let link = fs::read_link(&source)?;
|
||||
let link = fs::read_link(source)?;
|
||||
let dest: Cow<'_, Path> = if dest.is_dir() {
|
||||
match source.file_name() {
|
||||
Some(name) => dest.join(name).into(),
|
||||
|
@ -1695,8 +1695,8 @@ pub fn verify_target_type(target: &Path, target_type: &TargetType) -> CopyResult
|
|||
/// ).unwrap() == Path::new("target/c.txt"))
|
||||
/// ```
|
||||
pub fn localize_to_target(root: &Path, source: &Path, target: &Path) -> CopyResult<PathBuf> {
|
||||
let local_to_root = source.strip_prefix(&root)?;
|
||||
Ok(target.join(&local_to_root))
|
||||
let local_to_root = source.strip_prefix(root)?;
|
||||
Ok(target.join(local_to_root))
|
||||
}
|
||||
|
||||
pub fn path_has_prefix(p1: &Path, p2: &Path) -> io::Result<bool> {
|
||||
|
|
|
@ -368,7 +368,7 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) -> UResult<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
show_if_err!(File::open(&path)
|
||||
show_if_err!(File::open(path)
|
||||
.map_err_context(|| filename.maybe_quote().to_string())
|
||||
.and_then(|file| {
|
||||
match &mode {
|
||||
|
|
|
@ -492,7 +492,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
|
|||
let exclude_from_iterator = matches
|
||||
.get_many::<String>(options::EXCLUDE_FROM)
|
||||
.unwrap_or_default()
|
||||
.flat_map(|f| file_as_vec(&f));
|
||||
.flat_map(file_as_vec);
|
||||
|
||||
let excludes_iterator = matches
|
||||
.get_many::<String>(options::EXCLUDE)
|
||||
|
@ -913,7 +913,7 @@ impl FromStr for Threshold {
|
|||
type Err = ParseSizeError;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
let offset = if s.starts_with(&['-', '+'][..]) { 1 } else { 0 };
|
||||
let offset = usize::from(s.starts_with(&['-', '+'][..]));
|
||||
|
||||
let size = parse_size(&s[offset..])?;
|
||||
|
||||
|
|
|
@ -505,11 +505,7 @@ fn prefix_operator_substr(values: &[String]) -> String {
|
|||
}
|
||||
|
||||
fn bool_as_int(b: bool) -> u8 {
|
||||
if b {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
u8::from(b)
|
||||
}
|
||||
fn bool_as_string(b: bool) -> String {
|
||||
if b {
|
||||
|
|
|
@ -275,7 +275,7 @@ impl Params {
|
|||
// For example, if `tmpdir` is "a/b" and the template is "c/dXXX",
|
||||
// then `prefix` is "a/b/c/d".
|
||||
let tmpdir = options.tmpdir;
|
||||
let prefix_from_option = tmpdir.clone().unwrap_or_else(|| "".to_string());
|
||||
let prefix_from_option = tmpdir.clone().unwrap_or_default();
|
||||
let prefix_from_template = &options.template[..i];
|
||||
let prefix = Path::new(&prefix_from_option)
|
||||
.join(prefix_from_template)
|
||||
|
@ -311,7 +311,7 @@ impl Params {
|
|||
//
|
||||
// For example, if the suffix command-line argument is ".txt" and
|
||||
// the template is "XXXabc", then `suffix` is "abc.txt".
|
||||
let suffix_from_option = options.suffix.unwrap_or_else(|| "".to_string());
|
||||
let suffix_from_option = options.suffix.unwrap_or_default();
|
||||
let suffix_from_template = &options.template[j..];
|
||||
let suffix = format!("{}{}", suffix_from_template, suffix_from_option);
|
||||
if suffix.contains(MAIN_SEPARATOR) {
|
||||
|
@ -484,7 +484,7 @@ pub fn dry_exec(tmpdir: &str, prefix: &str, rand: usize, suffix: &str) -> UResul
|
|||
fn make_temp_dir(dir: &str, prefix: &str, rand: usize, suffix: &str) -> UResult<PathBuf> {
|
||||
let mut builder = Builder::new();
|
||||
builder.prefix(prefix).rand_bytes(rand).suffix(suffix);
|
||||
match builder.tempdir_in(&dir) {
|
||||
match builder.tempdir_in(dir) {
|
||||
Ok(d) => {
|
||||
// `into_path` consumes the TempDir without removing it
|
||||
let path = d.into_path();
|
||||
|
@ -516,7 +516,7 @@ fn make_temp_dir(dir: &str, prefix: &str, rand: usize, suffix: &str) -> UResult<
|
|||
fn make_temp_file(dir: &str, prefix: &str, rand: usize, suffix: &str) -> UResult<PathBuf> {
|
||||
let mut builder = Builder::new();
|
||||
builder.prefix(prefix).rand_bytes(rand).suffix(suffix);
|
||||
match builder.tempfile_in(&dir) {
|
||||
match builder.tempfile_in(dir) {
|
||||
// `keep` ensures that the file is not deleted
|
||||
Ok(named_tempfile) => match named_tempfile.keep() {
|
||||
Ok((_, pathbuf)) => Ok(pathbuf),
|
||||
|
|
|
@ -453,7 +453,7 @@ fn rename_symlink_fallback(from: &Path, to: &Path) -> io::Result<()> {
|
|||
let path_symlink_points_to = fs::read_link(from)?;
|
||||
#[cfg(unix)]
|
||||
{
|
||||
unix::fs::symlink(&path_symlink_points_to, &to).and_then(|_| fs::remove_file(&from))?;
|
||||
unix::fs::symlink(&path_symlink_points_to, to).and_then(|_| fs::remove_file(from))?;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
|
|
|
@ -279,7 +279,7 @@ fn nl<T: Read>(reader: &mut BufReader<T>, settings: &Settings) -> UResult<()> {
|
|||
// If we have already seen three groups (corresponding to
|
||||
// a header) or the current char does not form part of
|
||||
// a new group, then this line is not a segment indicator.
|
||||
if matched_groups >= 3 || settings.section_delimiter[if odd { 1 } else { 0 }] != c {
|
||||
if matched_groups >= 3 || settings.section_delimiter[usize::from(odd)] != c {
|
||||
matched_groups = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1086,7 +1086,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
let mut files = Vec::new();
|
||||
for path in &files0_from {
|
||||
let reader = open(&path)?;
|
||||
let reader = open(path)?;
|
||||
let buf_reader = BufReader::new(reader);
|
||||
for line in buf_reader.split(b'\0').flatten() {
|
||||
files.push(OsString::from(
|
||||
|
|
|
@ -80,7 +80,7 @@ impl TmpDirWrapper {
|
|||
/// Remove the directory at `path` by deleting its child files and then itself.
|
||||
/// Errors while deleting child files are ignored.
|
||||
fn remove_tmp_dir(path: &Path) -> std::io::Result<()> {
|
||||
if let Ok(read_dir) = std::fs::read_dir(&path) {
|
||||
if let Ok(read_dir) = std::fs::read_dir(path) {
|
||||
for file in read_dir.flatten() {
|
||||
// if we fail to delete the file here it was probably deleted by another thread
|
||||
// in the meantime, but that's ok.
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Drop for WithEnvVarSet {
|
|||
/// Restore previous value now that this is being dropped by context
|
||||
fn drop(&mut self) {
|
||||
if let Ok(ref prev_value) = self._previous_var_value {
|
||||
env::set_var(&self._previous_var_key, &prev_value);
|
||||
env::set_var(&self._previous_var_key, prev_value);
|
||||
} else {
|
||||
env::remove_var(&self._previous_var_key);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.short(options::INPUT_SHORT)
|
||||
.help("adjust standard input stream buffering")
|
||||
.value_name("MODE")
|
||||
.required_unless_present_any(&[options::OUTPUT, options::ERROR]),
|
||||
.required_unless_present_any([options::OUTPUT, options::ERROR]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::OUTPUT)
|
||||
|
@ -215,7 +215,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.short(options::OUTPUT_SHORT)
|
||||
.help("adjust standard output stream buffering")
|
||||
.value_name("MODE")
|
||||
.required_unless_present_any(&[options::INPUT, options::ERROR]),
|
||||
.required_unless_present_any([options::INPUT, options::ERROR]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ERROR)
|
||||
|
@ -223,7 +223,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
.short(options::ERROR_SHORT)
|
||||
.help("adjust standard error stream buffering")
|
||||
.value_name("MODE")
|
||||
.required_unless_present_any(&[options::INPUT, options::OUTPUT]),
|
||||
.required_unless_present_any([options::INPUT, options::OUTPUT]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::COMMAND)
|
||||
|
|
|
@ -122,7 +122,7 @@ impl FileHandling {
|
|||
*/
|
||||
self.get_mut(path)
|
||||
.reader
|
||||
.replace(Box::new(BufReader::new(File::open(&path)?)));
|
||||
.replace(Box::new(BufReader::new(File::open(path)?)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ fn tail_file(
|
|||
watcher_service.add_bad_path(path, input.display_name.as_str(), false)?;
|
||||
} else if input.is_tailable() {
|
||||
let metadata = path.metadata().ok();
|
||||
match File::open(&path) {
|
||||
match File::open(path) {
|
||||
Ok(mut file) => {
|
||||
input_service.print_header(input);
|
||||
let mut reader;
|
||||
|
|
|
@ -220,7 +220,7 @@ fn open(path: &str) -> BufReader<Box<dyn Read + 'static>> {
|
|||
if path == "-" {
|
||||
BufReader::new(Box::new(stdin()) as Box<dyn Read>)
|
||||
} else {
|
||||
file_buf = match File::open(&path) {
|
||||
file_buf = match File::open(path) {
|
||||
Ok(a) => a,
|
||||
Err(e) => crash!(1, "{}: {}", path.maybe_quote(), e),
|
||||
};
|
||||
|
|
|
@ -424,7 +424,7 @@ fn open_input_file(in_file_name: &str) -> UResult<BufReader<Box<dyn Read + 'stat
|
|||
Box::new(stdin()) as Box<dyn Read>
|
||||
} else {
|
||||
let path = Path::new(in_file_name);
|
||||
let in_file = File::open(&path)
|
||||
let in_file = File::open(path)
|
||||
.map_err_context(|| format!("Could not open {}", in_file_name.maybe_quote()))?;
|
||||
Box::new(in_file) as Box<dyn Read>
|
||||
};
|
||||
|
@ -436,7 +436,7 @@ fn open_output_file(out_file_name: &str) -> UResult<BufWriter<Box<dyn Write + 's
|
|||
Box::new(stdout()) as Box<dyn Write>
|
||||
} else {
|
||||
let path = Path::new(out_file_name);
|
||||
let out_file = File::create(&path)
|
||||
let out_file = File::create(path)
|
||||
.map_err_context(|| format!("Could not create {}", out_file_name.maybe_quote()))?;
|
||||
Box::new(out_file) as Box<dyn Write>
|
||||
};
|
||||
|
|
|
@ -355,7 +355,7 @@ pub fn canonicalize<P: AsRef<Path>>(
|
|||
followed_symlinks += 1;
|
||||
} else {
|
||||
let file_info =
|
||||
FileInformation::from_path(&result.parent().unwrap(), false).unwrap();
|
||||
FileInformation::from_path(result.parent().unwrap(), false).unwrap();
|
||||
let mut path_to_follow = PathBuf::new();
|
||||
for part in &parts {
|
||||
path_to_follow.push(part.as_os_str());
|
||||
|
|
|
@ -76,9 +76,10 @@ fn test_wrap() {
|
|||
#[test]
|
||||
fn test_wrap_no_arg() {
|
||||
for wrap_param in ["-w", "--wrap"] {
|
||||
new_ucmd!().arg(wrap_param).fails().stderr_contains(
|
||||
&"The argument '--wrap <wrap>' requires a value but none was supplied",
|
||||
);
|
||||
new_ucmd!()
|
||||
.arg(wrap_param)
|
||||
.fails()
|
||||
.stderr_contains("The argument '--wrap <wrap>' requires a value but none was supplied");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::ffi::OsStr;
|
|||
fn test_help() {
|
||||
for help_flg in ["-h", "--help"] {
|
||||
new_ucmd!()
|
||||
.arg(&help_flg)
|
||||
.arg(help_flg)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_contains("USAGE:");
|
||||
|
@ -19,7 +19,7 @@ fn test_help() {
|
|||
fn test_version() {
|
||||
for version_flg in ["-V", "--version"] {
|
||||
assert!(new_ucmd!()
|
||||
.arg(&version_flg)
|
||||
.arg(version_flg)
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_str()
|
||||
|
|
|
@ -380,7 +380,7 @@ fn test_chmod_non_existing_file() {
|
|||
.arg("-r,a+w")
|
||||
.arg("does-not-exist")
|
||||
.fails()
|
||||
.stderr_contains(&"cannot access 'does-not-exist': No such file or directory");
|
||||
.stderr_contains("cannot access 'does-not-exist': No such file or directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -403,7 +403,7 @@ fn test_chmod_preserve_root() {
|
|||
.arg("755")
|
||||
.arg("/")
|
||||
.fails()
|
||||
.stderr_contains(&"chmod: it is dangerous to operate recursively on '/'");
|
||||
.stderr_contains("chmod: it is dangerous to operate recursively on '/'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -107,7 +107,7 @@ fn test_chown_only_owner() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
// try to change to another existing user, e.g. 'root'
|
||||
scene
|
||||
|
@ -116,7 +116,7 @@ fn test_chown_only_owner() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -142,7 +142,7 @@ fn test_chown_only_owner_colon() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.succeeds()
|
||||
.stderr_contains(&"retained as");
|
||||
.stderr_contains("retained as");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -150,7 +150,7 @@ fn test_chown_only_owner_colon() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.succeeds()
|
||||
.stderr_contains(&"retained as");
|
||||
.stderr_contains("retained as");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -158,7 +158,7 @@ fn test_chown_only_owner_colon() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -179,7 +179,7 @@ fn test_chown_only_colon() {
|
|||
if skipping_test_is_okay(&result, "No such id") {
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as"); // TODO: verbose is not printed to stderr in GNU chown
|
||||
result.stderr_contains("retained as"); // TODO: verbose is not printed to stderr in GNU chown
|
||||
|
||||
// test chown : file.txt
|
||||
// expected:
|
||||
|
@ -192,7 +192,7 @@ fn test_chown_only_colon() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"invalid group: '::'");
|
||||
.stderr_contains("invalid group: '::'");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -200,7 +200,7 @@ fn test_chown_only_colon() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"invalid group: '..'");
|
||||
.stderr_contains("invalid group: '..'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -251,7 +251,7 @@ fn test_chown_owner_group() {
|
|||
if skipping_test_is_okay(&result, "chown: invalid group:") {
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -259,7 +259,7 @@ fn test_chown_owner_group() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"invalid group");
|
||||
.stderr_contains("invalid group");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -267,7 +267,7 @@ fn test_chown_owner_group() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"invalid group");
|
||||
.stderr_contains("invalid group");
|
||||
|
||||
// TODO: on macos group name is not recognized correctly: "chown: invalid group: 'root:root'
|
||||
#[cfg(any(windows, all(unix, not(target_os = "macos"))))]
|
||||
|
@ -277,7 +277,7 @@ fn test_chown_owner_group() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -316,7 +316,7 @@ fn test_chown_various_input() {
|
|||
if skipping_test_is_okay(&result, "chown: invalid group:") {
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
// check that username.groupname is understood
|
||||
let result = scene
|
||||
|
@ -328,7 +328,7 @@ fn test_chown_various_input() {
|
|||
if skipping_test_is_okay(&result, "chown: invalid group:") {
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
// Fails as user.name doesn't exist in the CI
|
||||
// but it is valid
|
||||
|
@ -338,7 +338,7 @@ fn test_chown_various_input() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"chown: invalid user: 'user.name:groupname'");
|
||||
.stderr_contains("chown: invalid user: 'user.name:groupname'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -377,7 +377,7 @@ fn test_chown_only_group() {
|
|||
// With mac into the CI, we can get this answer
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
result.success();
|
||||
|
||||
scene
|
||||
|
@ -386,7 +386,7 @@ fn test_chown_only_group() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -412,7 +412,7 @@ fn test_chown_only_user_id() {
|
|||
// stderr: "chown: invalid user: '1001'
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -420,7 +420,7 @@ fn test_chown_only_user_id() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
/// Test for setting the owner to a user ID for a user that does not exist.
|
||||
|
@ -475,7 +475,7 @@ fn test_chown_only_group_id() {
|
|||
// With mac into the CI, we can get this answer
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
// Apparently on CI "macos-latest, x86_64-apple-darwin, feat_os_macos"
|
||||
// the process has the rights to change from runner:staff to runner:wheel
|
||||
|
@ -486,7 +486,7 @@ fn test_chown_only_group_id() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
/// Test for setting the group to a group ID for a group that does not exist.
|
||||
|
@ -547,7 +547,7 @@ fn test_chown_owner_group_id() {
|
|||
// stderr: "chown: invalid user: '1001:116'
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
|
@ -560,7 +560,7 @@ fn test_chown_owner_group_id() {
|
|||
// stderr: "chown: invalid user: '1001.116'
|
||||
return;
|
||||
}
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -568,7 +568,7 @@ fn test_chown_owner_group_id() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -603,7 +603,7 @@ fn test_chown_owner_group_mix() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
result.stderr_contains(&"retained as");
|
||||
result.stderr_contains("retained as");
|
||||
|
||||
// TODO: on macos group name is not recognized correctly: "chown: invalid group: '0:root'
|
||||
#[cfg(any(windows, all(unix, not(target_os = "macos"))))]
|
||||
|
@ -613,7 +613,7 @@ fn test_chown_owner_group_mix() {
|
|||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains(&"failed to change");
|
||||
.stderr_contains("failed to change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -643,8 +643,8 @@ fn test_chown_recursive() {
|
|||
.arg("a")
|
||||
.arg("z")
|
||||
.run();
|
||||
result.stderr_contains(&"ownership of 'a/a' retained as");
|
||||
result.stderr_contains(&"ownership of 'z/y' retained as");
|
||||
result.stderr_contains("ownership of 'a/a' retained as");
|
||||
result.stderr_contains("ownership of 'z/y' retained as");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -665,7 +665,7 @@ fn test_root_preserve() {
|
|||
.arg(user_name)
|
||||
.arg("/")
|
||||
.fails();
|
||||
result.stderr_contains(&"chown: it is dangerous to operate recursively");
|
||||
result.stderr_contains("chown: it is dangerous to operate recursively");
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
|
|
@ -352,7 +352,7 @@ fn test_install_target_new_file_failing_nonexistent_parent() {
|
|||
ucmd.arg(file1)
|
||||
.arg(format!("{}/{}", dir, file2))
|
||||
.fails()
|
||||
.stderr_contains(&"No such file or directory");
|
||||
.stderr_contains("No such file or directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -561,8 +561,8 @@ fn test_ls_a() {
|
|||
.arg("-a")
|
||||
.arg("-1")
|
||||
.succeeds()
|
||||
.stdout_contains(&".test-1")
|
||||
.stdout_contains(&"..")
|
||||
.stdout_contains(".test-1")
|
||||
.stdout_contains("..")
|
||||
.stdout_matches(&re_pwd);
|
||||
|
||||
scene
|
||||
|
@ -590,8 +590,8 @@ fn test_ls_a() {
|
|||
.arg("-1")
|
||||
.arg("some-dir")
|
||||
.succeeds()
|
||||
.stdout_contains(&".test-2")
|
||||
.stdout_contains(&"..")
|
||||
.stdout_contains(".test-2")
|
||||
.stdout_contains("..")
|
||||
.no_stderr()
|
||||
.stdout_matches(&re_pwd);
|
||||
|
||||
|
@ -1821,7 +1821,7 @@ fn test_ls_files_dirs() {
|
|||
.ucmd()
|
||||
.arg("doesntexist")
|
||||
.fails()
|
||||
.stderr_contains(&"'doesntexist': No such file or directory");
|
||||
.stderr_contains("'doesntexist': No such file or directory");
|
||||
|
||||
// One exists, the other doesn't
|
||||
scene
|
||||
|
@ -1829,8 +1829,8 @@ fn test_ls_files_dirs() {
|
|||
.arg("a")
|
||||
.arg("doesntexist")
|
||||
.fails()
|
||||
.stderr_contains(&"'doesntexist': No such file or directory")
|
||||
.stdout_contains(&"a:");
|
||||
.stderr_contains("'doesntexist': No such file or directory")
|
||||
.stdout_contains("a:");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1851,7 +1851,7 @@ fn test_ls_recursive() {
|
|||
.arg("z")
|
||||
.arg("-R")
|
||||
.succeeds()
|
||||
.stdout_contains(&"z:");
|
||||
.stdout_contains("z:");
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg("--color=never")
|
||||
|
@ -1861,7 +1861,7 @@ fn test_ls_recursive() {
|
|||
.succeeds();
|
||||
|
||||
#[cfg(not(windows))]
|
||||
result.stdout_contains(&"a/b:\nb");
|
||||
result.stdout_contains("a/b:\nb");
|
||||
#[cfg(windows)]
|
||||
result.stdout_contains(&"a\\b:\nb");
|
||||
}
|
||||
|
@ -2014,7 +2014,7 @@ fn test_ls_indicator_style() {
|
|||
"-p",
|
||||
] {
|
||||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
scene.ucmd().arg(opt).succeeds().stdout_contains(&"/");
|
||||
scene.ucmd().arg(opt).succeeds().stdout_contains("/");
|
||||
}
|
||||
|
||||
// Classify, Indicator options should not contain any indicators when value is none.
|
||||
|
@ -2030,9 +2030,9 @@ fn test_ls_indicator_style() {
|
|||
.ucmd()
|
||||
.arg(opt)
|
||||
.succeeds()
|
||||
.stdout_does_not_contain(&"/")
|
||||
.stdout_does_not_contain(&"@")
|
||||
.stdout_does_not_contain(&"|");
|
||||
.stdout_does_not_contain("/")
|
||||
.stdout_does_not_contain("@")
|
||||
.stdout_does_not_contain("|");
|
||||
}
|
||||
|
||||
// Classify and File-Type all contain indicators for pipes and links.
|
||||
|
@ -2043,8 +2043,8 @@ fn test_ls_indicator_style() {
|
|||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.succeeds()
|
||||
.stdout_contains(&"@")
|
||||
.stdout_contains(&"|");
|
||||
.stdout_contains("@")
|
||||
.stdout_contains("|");
|
||||
}
|
||||
|
||||
// Test sockets. Because the canonical way of making sockets to test is with
|
||||
|
@ -2631,7 +2631,7 @@ fn test_ls_ignore_hide() {
|
|||
.arg("--ignore=READ[ME")
|
||||
.arg("-1")
|
||||
.succeeds()
|
||||
.stderr_contains(&"Invalid pattern")
|
||||
.stderr_contains("Invalid pattern")
|
||||
.stdout_is("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
|
||||
|
||||
scene
|
||||
|
@ -2639,7 +2639,7 @@ fn test_ls_ignore_hide() {
|
|||
.arg("--hide=READ[ME")
|
||||
.arg("-1")
|
||||
.succeeds()
|
||||
.stderr_contains(&"Invalid pattern")
|
||||
.stderr_contains("Invalid pattern")
|
||||
.stdout_is("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ fn test_mknod_fifo_invalid_extra_operand() {
|
|||
.arg("1")
|
||||
.arg("2")
|
||||
.fails()
|
||||
.stderr_contains(&"Fifos do not have major and minor device numbers");
|
||||
.stderr_contains("Fifos do not have major and minor device numbers");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -78,28 +78,28 @@ fn test_mknod_character_device_requires_major_and_minor() {
|
|||
.arg("c")
|
||||
.fails()
|
||||
.status_code(1)
|
||||
.stderr_contains(&"Special files require major and minor device numbers.");
|
||||
.stderr_contains("Special files require major and minor device numbers.");
|
||||
new_ucmd!()
|
||||
.arg("test_file")
|
||||
.arg("c")
|
||||
.arg("1")
|
||||
.fails()
|
||||
.status_code(1)
|
||||
.stderr_contains(&"Special files require major and minor device numbers.");
|
||||
.stderr_contains("Special files require major and minor device numbers.");
|
||||
new_ucmd!()
|
||||
.arg("test_file")
|
||||
.arg("c")
|
||||
.arg("1")
|
||||
.arg("c")
|
||||
.fails()
|
||||
.stderr_contains(&"Invalid value \"c\" for '<MINOR>'");
|
||||
.stderr_contains("Invalid value \"c\" for '<MINOR>'");
|
||||
new_ucmd!()
|
||||
.arg("test_file")
|
||||
.arg("c")
|
||||
.arg("c")
|
||||
.arg("1")
|
||||
.fails()
|
||||
.stderr_contains(&"Invalid value \"c\" for '<MAJOR>'");
|
||||
.stderr_contains("Invalid value \"c\" for '<MAJOR>'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -109,7 +109,7 @@ fn test_mknod_invalid_arg() {
|
|||
.arg("--foo")
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains(&"Found argument '--foo' which wasn't expected");
|
||||
.stderr_contains("Found argument '--foo' which wasn't expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -123,5 +123,5 @@ fn test_mknod_invalid_mode() {
|
|||
.fails()
|
||||
.no_stdout()
|
||||
.status_code(1)
|
||||
.stderr_contains(&"invalid mode");
|
||||
.stderr_contains("invalid mode");
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ fn test_2files() {
|
|||
|
||||
// spell-checker:disable-next-line
|
||||
for (path, data) in [(&file1, "abcdefghijklmnop"), (&file2, "qrstuvwxyz\n")] {
|
||||
let mut f = File::create(&path).unwrap();
|
||||
let mut f = File::create(path).unwrap();
|
||||
assert!(
|
||||
f.write_all(data.as_bytes()).is_ok(),
|
||||
"Test setup failed - could not write file"
|
||||
|
@ -133,7 +133,7 @@ fn test_from_mixed() {
|
|||
// spell-checker:disable-next-line
|
||||
let (data1, data2, data3) = ("abcdefg", "hijklmnop", "qrstuvwxyz\n");
|
||||
for (path, data) in [(&file1, data1), (&file3, data3)] {
|
||||
let mut f = File::create(&path).unwrap();
|
||||
let mut f = File::create(path).unwrap();
|
||||
assert!(
|
||||
f.write_all(data.as_bytes()).is_ok(),
|
||||
"Test setup failed - could not write file"
|
||||
|
|
|
@ -282,7 +282,7 @@ fn test_filter_with_env_var_set() {
|
|||
RandomFile::new(&at, name).add_lines(n_lines);
|
||||
|
||||
let env_var_value = "some-value";
|
||||
env::set_var("FILE", &env_var_value);
|
||||
env::set_var("FILE", env_var_value);
|
||||
ucmd.args(&[format!("--filter={}", "cat > $FILE").as_str(), name])
|
||||
.succeeds();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ fn test_tee_no_more_writeable_1() {
|
|||
.pipe_in(&content[..])
|
||||
.fails()
|
||||
.stdout_contains(&content)
|
||||
.stderr_contains(&"No space left on device");
|
||||
.stderr_contains("No space left on device");
|
||||
|
||||
assert_eq!(at.read(file_out), content);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ fn test_count_bytes_large_stdin() {
|
|||
.args(&["-c"])
|
||||
.pipe_in(data)
|
||||
.succeeds()
|
||||
.stdout_is_bytes(&expected.as_bytes());
|
||||
.stdout_is_bytes(expected.as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,25 +183,25 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_random_string_generate() {
|
||||
let random_string = RandomString::generate(&AlphanumericNewline, 0);
|
||||
let random_string = RandomString::generate(AlphanumericNewline, 0);
|
||||
assert_eq!(0, random_string.len());
|
||||
|
||||
let random_string = RandomString::generate(&AlphanumericNewline, 1);
|
||||
let random_string = RandomString::generate(AlphanumericNewline, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
|
||||
let random_string = RandomString::generate(&AlphanumericNewline, 100);
|
||||
let random_string = RandomString::generate(AlphanumericNewline, 100);
|
||||
assert_eq!(100, random_string.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_random_string_generate_with_delimiter_when_length_is_zero() {
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 0, false, 0);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, false, 0);
|
||||
assert_eq!(0, random_string.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_random_string_generate_with_delimiter_when_num_delimiter_is_greater_than_length() {
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 2, false, 1);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 2, false, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
assert!(random_string.as_bytes().contains(&0));
|
||||
assert!(random_string.as_bytes().ends_with(&[0]));
|
||||
|
@ -209,7 +209,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_random_string_generate_with_delimiter_should_end_with_delimiter() {
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, true, 1);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -217,7 +217,7 @@ mod tests {
|
|||
);
|
||||
assert!(random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, false, 1);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, false, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -225,7 +225,7 @@ mod tests {
|
|||
);
|
||||
assert!(random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, true, 2);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 2);
|
||||
assert_eq!(2, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -233,7 +233,7 @@ mod tests {
|
|||
);
|
||||
assert!(random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 2, true, 2);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 2, true, 2);
|
||||
assert_eq!(2, random_string.len());
|
||||
assert_eq!(
|
||||
2,
|
||||
|
@ -241,7 +241,7 @@ mod tests {
|
|||
);
|
||||
assert!(random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, true, 3);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, true, 3);
|
||||
assert_eq!(3, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -252,21 +252,21 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_random_string_generate_with_delimiter_should_not_end_with_delimiter() {
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 0, false, 1);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, false, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
assert_eq!(
|
||||
0,
|
||||
random_string.as_bytes().iter().filter(|p| **p == 0).count()
|
||||
);
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 0, true, 1);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 0, true, 1);
|
||||
assert_eq!(1, random_string.len());
|
||||
assert_eq!(
|
||||
0,
|
||||
random_string.as_bytes().iter().filter(|p| **p == 0).count()
|
||||
);
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, false, 2);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, false, 2);
|
||||
assert_eq!(2, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -274,7 +274,7 @@ mod tests {
|
|||
);
|
||||
assert!(!random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 1, false, 3);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 1, false, 3);
|
||||
assert_eq!(3, random_string.len());
|
||||
assert_eq!(
|
||||
1,
|
||||
|
@ -282,7 +282,7 @@ mod tests {
|
|||
);
|
||||
assert!(!random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string = RandomString::generate_with_delimiter(&Alphanumeric, 0, 2, false, 3);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 2, false, 3);
|
||||
assert_eq!(3, random_string.len());
|
||||
assert_eq!(
|
||||
2,
|
||||
|
@ -294,7 +294,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_generate_with_delimiter_with_greater_length() {
|
||||
let random_string =
|
||||
RandomString::generate_with_delimiter(&Alphanumeric, 0, 100, false, 1000);
|
||||
RandomString::generate_with_delimiter(Alphanumeric, 0, 100, false, 1000);
|
||||
assert_eq!(1000, random_string.len());
|
||||
assert_eq!(
|
||||
100,
|
||||
|
@ -302,8 +302,7 @@ mod tests {
|
|||
);
|
||||
assert!(!random_string.as_bytes().ends_with(&[0]));
|
||||
|
||||
let random_string =
|
||||
RandomString::generate_with_delimiter(&Alphanumeric, 0, 100, true, 1000);
|
||||
let random_string = RandomString::generate_with_delimiter(Alphanumeric, 0, 100, true, 1000);
|
||||
assert_eq!(1000, random_string.len());
|
||||
assert_eq!(
|
||||
100,
|
||||
|
@ -325,7 +324,7 @@ mod tests {
|
|||
|
||||
let length = 8192 * 3 + 1;
|
||||
let random_string =
|
||||
RandomString::generate_with_delimiter(&Alphanumeric, b'\n', 100, true, length);
|
||||
RandomString::generate_with_delimiter(Alphanumeric, b'\n', 100, true, length);
|
||||
assert_eq!(length, random_string.len());
|
||||
assert_eq!(
|
||||
100,
|
||||
|
|
|
@ -710,7 +710,7 @@ impl AtPath {
|
|||
"symlink",
|
||||
&format!("{},{}", &original, &self.plus_as_string(link)),
|
||||
);
|
||||
symlink_file(&original, &self.plus(link)).unwrap();
|
||||
symlink_file(original, &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn symlink_dir(&self, original: &str, link: &str) {
|
||||
|
@ -732,7 +732,7 @@ impl AtPath {
|
|||
"symlink",
|
||||
&format!("{},{}", &original, &self.plus_as_string(link)),
|
||||
);
|
||||
symlink_dir(&original, &self.plus(link)).unwrap();
|
||||
symlink_dir(original, &self.plus(link)).unwrap();
|
||||
}
|
||||
|
||||
pub fn is_symlink(&self, path: &str) -> bool {
|
||||
|
@ -1445,7 +1445,7 @@ pub fn run_ucmd_as_root(
|
|||
log_info("run", "sudo -E --non-interactive whoami");
|
||||
match Command::new("sudo")
|
||||
.env("LC_ALL", "C")
|
||||
.args(&["-E", "--non-interactive", "whoami"])
|
||||
.args(["-E", "--non-interactive", "whoami"])
|
||||
.output()
|
||||
{
|
||||
Ok(output) if String::from_utf8_lossy(&output.stdout).eq("root\n") => {
|
||||
|
@ -1833,7 +1833,7 @@ mod tests {
|
|||
// Skip test if we can't guarantee non-interactive `sudo`, or if we're not "root"
|
||||
if let Ok(output) = Command::new("sudo")
|
||||
.env("LC_ALL", "C")
|
||||
.args(&["-E", "--non-interactive", "whoami"])
|
||||
.args(["-E", "--non-interactive", "whoami"])
|
||||
.output()
|
||||
{
|
||||
if output.status.success() && String::from_utf8_lossy(&output.stdout).eq("root\n") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue