mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
fix clippy tests
This commit is contained in:
@@ -485,7 +485,7 @@ fn test_dev_random() {
|
||||
}
|
||||
|
||||
/// Reading from /dev/full should return an infinite amount of zero bytes.
|
||||
/// Wikipedia says there is support on Linux, FreeBSD, and NetBSD.
|
||||
/// Wikipedia says there is support on Linux, FreeBSD, and `NetBSD`.
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||
fn test_dev_full() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (jargon) xattributes
|
||||
|
||||
#![allow(clippy::missing_errors_doc, clippy::similar_names)]
|
||||
#![cfg(feature = "feat_selinux")]
|
||||
|
||||
use std::ffi::CString;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use crate::common::util::{AtPath, TestScenario, UCommand};
|
||||
use std::fs::{metadata, set_permissions, OpenOptions, Permissions};
|
||||
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
||||
@@ -32,12 +33,14 @@ fn make_file(file: &str, mode: u32) {
|
||||
fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
||||
make_file(&at.plus_as_string(TEST_FILE), test.before);
|
||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
if perms != test.before {
|
||||
panic!(
|
||||
"{}: expected: {:o} got: {:o}",
|
||||
"setting permissions on test files before actual test run failed", test.after, perms
|
||||
);
|
||||
}
|
||||
|
||||
assert!(
|
||||
perms == test.before,
|
||||
"{}: expected: {:o} got: {:o}",
|
||||
"setting permissions on test files before actual test run failed",
|
||||
test.after,
|
||||
perms
|
||||
);
|
||||
|
||||
for arg in &test.args {
|
||||
ucmd.arg(arg);
|
||||
@@ -52,9 +55,13 @@ fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
||||
}
|
||||
|
||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
if perms != test.after {
|
||||
panic!("{}: expected: {:o} got: {:o}", ucmd, test.after, perms);
|
||||
}
|
||||
assert!(
|
||||
perms == test.after,
|
||||
"{}: expected: {:o} got: {:o}",
|
||||
ucmd,
|
||||
test.after,
|
||||
perms
|
||||
);
|
||||
}
|
||||
|
||||
fn run_tests(tests: Vec<TestCase>) {
|
||||
@@ -128,6 +135,7 @@ fn test_chmod_octal() {
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
// spell-checker:disable-next-line
|
||||
fn test_chmod_ugoa() {
|
||||
let tests = vec![
|
||||
|
||||
@@ -29,9 +29,8 @@ fn skipping_test_is_okay(result: &CmdResult, needle: &str) -> bool {
|
||||
if is_ci() && result.stderr_str().contains(needle) {
|
||||
println!("test skipped:");
|
||||
return true;
|
||||
} else {
|
||||
result.success();
|
||||
}
|
||||
result.success();
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
+11
-11
@@ -2298,9 +2298,9 @@ fn test_closes_file_descriptors() {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[test]
|
||||
fn test_cp_sparse_never_empty() {
|
||||
const BUFFER_SIZE: usize = 4096 * 4;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
const BUFFER_SIZE: usize = 4096 * 4;
|
||||
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
|
||||
|
||||
at.make_file("src_file1");
|
||||
@@ -2318,10 +2318,10 @@ fn test_cp_sparse_never_empty() {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[test]
|
||||
fn test_cp_sparse_always_empty() {
|
||||
const BUFFER_SIZE: usize = 4096 * 4;
|
||||
for argument in ["--sparse=always", "--sparse=alway", "--sparse=al"] {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
const BUFFER_SIZE: usize = 4096 * 4;
|
||||
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
|
||||
|
||||
at.make_file("src_file1");
|
||||
@@ -2338,9 +2338,9 @@ fn test_cp_sparse_always_empty() {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[test]
|
||||
fn test_cp_sparse_always_non_empty() {
|
||||
const BUFFER_SIZE: usize = 4096 * 16 + 3;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
const BUFFER_SIZE: usize = 4096 * 16 + 3;
|
||||
let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
|
||||
let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)];
|
||||
|
||||
@@ -2408,12 +2408,11 @@ fn test_cp_sparse_never_reflink_always() {
|
||||
#[cfg(feature = "truncate")]
|
||||
#[test]
|
||||
fn test_cp_reflink_always_override() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
||||
const DISK: &str = "disk.img";
|
||||
const ROOTDIR: &str = "disk_root/";
|
||||
const USERDIR: &str = "dir/";
|
||||
const MOUNTPOINT: &str = "mountpoint/";
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
||||
let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat();
|
||||
let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat();
|
||||
@@ -2545,12 +2544,12 @@ fn test_no_preserve_mode() {
|
||||
let umask: u16 = 0o022;
|
||||
ucmd.arg("file")
|
||||
.arg("dest")
|
||||
.umask(umask as libc::mode_t)
|
||||
.umask(libc::mode_t::from(umask))
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
// remove sticky bit, setuid and setgid bit; apply umask
|
||||
let expected_perms = PERMS_ALL & !0o7000 & !umask as u32;
|
||||
let expected_perms = PERMS_ALL & !0o7000 & u32::from(!umask);
|
||||
assert_eq!(
|
||||
at.plus("dest").metadata().unwrap().mode() & 0o7777,
|
||||
expected_perms
|
||||
@@ -5477,16 +5476,17 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
|
||||
let start_time = std::time::Instant::now();
|
||||
// wait for cp to create dirs
|
||||
loop {
|
||||
if start_time.elapsed() >= timeout {
|
||||
panic!("timed out: cp took too long to create destination directory")
|
||||
}
|
||||
assert!(
|
||||
start_time.elapsed() < timeout,
|
||||
"timed out: cp took too long to create destination directory"
|
||||
);
|
||||
if at.dir_exists(&format!("{}/{}", DEST_DIR, SRC_DIR)) {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
let mode = at.metadata(&format!("{}/{}", DEST_DIR, SRC_DIR)).mode();
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
#[allow(clippy::unnecessary_cast, clippy::cast_lossless)]
|
||||
let mask = if attr == "mode" {
|
||||
libc::S_IWGRP | libc::S_IWOTH
|
||||
} else {
|
||||
|
||||
@@ -263,7 +263,7 @@ fn test_date_set_mac_unavailable() {
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
/// TODO: expected to fail currently; change to succeeds() when required.
|
||||
/// TODO: expected to fail currently; change to `succeeds()` when required.
|
||||
fn test_date_set_valid_2() {
|
||||
if geteuid() == 0 {
|
||||
let result = new_ucmd!()
|
||||
@@ -288,10 +288,11 @@ fn test_date_for_invalid_file() {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_date_for_no_permission_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
const FILE: &str = "file-no-perm-1";
|
||||
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
@@ -328,7 +329,7 @@ fn test_date_for_file() {
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
/// TODO: expected to fail currently; change to succeeds() when required.
|
||||
/// TODO: expected to fail currently; change to `succeeds()` when required.
|
||||
fn test_date_set_valid_3() {
|
||||
if geteuid() == 0 {
|
||||
let result = new_ucmd!()
|
||||
@@ -342,7 +343,7 @@ fn test_date_set_valid_3() {
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
/// TODO: expected to fail currently; change to succeeds() when required.
|
||||
/// TODO: expected to fail currently; change to `succeeds()` when required.
|
||||
fn test_date_set_valid_4() {
|
||||
if geteuid() == 0 {
|
||||
let result = new_ucmd!()
|
||||
@@ -412,8 +413,8 @@ fn test_date_overflow() {
|
||||
|
||||
#[test]
|
||||
fn test_date_parse_from_format() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
const FILE: &str = "file-with-dates";
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.write(
|
||||
FILE,
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore udev pcent iuse itotal iused ipcent
|
||||
#![allow(
|
||||
clippy::similar_names,
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::float_cmp
|
||||
)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
|
||||
@@ -200,15 +200,15 @@ TERM {term_pattern}
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
let expectation_if_match = r#"
|
||||
let expectation_if_match = r"
|
||||
LS_COLORS='*.term_matching=00;38;5;61:';
|
||||
export LS_COLORS
|
||||
"#
|
||||
"
|
||||
.trim_start();
|
||||
let expectation_if_no_match = r#"
|
||||
let expectation_if_no_match = r"
|
||||
LS_COLORS='';
|
||||
export LS_COLORS
|
||||
"#
|
||||
"
|
||||
.trim_start();
|
||||
|
||||
// sanity checks
|
||||
|
||||
@@ -545,7 +545,7 @@ fn test_du_h_flag_empty_file() {
|
||||
#[test]
|
||||
fn test_du_h_precision() {
|
||||
let test_cases = [
|
||||
(133456345, "128M"),
|
||||
(133_456_345, "128M"),
|
||||
(12 * 1024 * 1024, "12M"),
|
||||
(8500, "8.4K"),
|
||||
];
|
||||
|
||||
+23
-22
@@ -3,6 +3,7 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) bamf chdir rlimit prlimit COMSPEC cout cerr FFFD
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(unix)]
|
||||
@@ -555,28 +556,28 @@ fn test_env_parsing_errors() {
|
||||
.stderr_is("env: invalid sequence '\\a' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S\|\&\;"#) // no quotes, invalid escape sequence |
|
||||
.arg(r"-S\|\&\;") // no quotes, invalid escape sequence |
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\|' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S\<\&\;"#) // no quotes, invalid escape sequence <
|
||||
.arg(r"-S\<\&\;") // no quotes, invalid escape sequence <
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\<' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S\>\&\;"#) // no quotes, invalid escape sequence >
|
||||
.arg(r"-S\>\&\;") // no quotes, invalid escape sequence >
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\>' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S\`\&\;"#) // no quotes, invalid escape sequence `
|
||||
.arg(r"-S\`\&\;") // no quotes, invalid escape sequence `
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
@@ -590,14 +591,14 @@ fn test_env_parsing_errors() {
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S'\`\&\;'"#) // single quotes, invalid escape sequence `
|
||||
.arg(r"-S'\`\&\;'") // single quotes, invalid escape sequence `
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S\`"#) // ` escaped without quotes
|
||||
.arg(r"-S\`") // ` escaped without quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
@@ -611,14 +612,14 @@ fn test_env_parsing_errors() {
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S'\`'"#) // ` escaped in single quotes
|
||||
.arg(r"-S'\`'") // ` escaped in single quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.args(&[r#"-S\🦉"#]) // ` escaped in single quotes
|
||||
.args(&[r"-S\🦉"]) // ` escaped in single quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.no_stdout()
|
||||
@@ -1068,11 +1069,11 @@ mod tests_split_iterator {
|
||||
#[test]
|
||||
fn split_single_quotes() {
|
||||
split_ok(&[
|
||||
(r#"''"#, &[r#""#]),
|
||||
(r#"'a'"#, &[r#"a"#]),
|
||||
(r#"'\\'"#, &[r#"\"#]),
|
||||
(r#"' \\ '"#, &[r#" \ "#]),
|
||||
(r#"'#'"#, &[r#"#"#]),
|
||||
(r"''", &[r""]),
|
||||
(r"'a'", &[r"a"]),
|
||||
(r"'\\'", &[r"\"]),
|
||||
(r"' \\ '", &[r" \ "]),
|
||||
(r"'#'", &[r"#"]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1094,12 +1095,12 @@ mod tests_split_iterator {
|
||||
#[test]
|
||||
fn split_unquoted() {
|
||||
split_ok(&[
|
||||
(r#"\\|\\&\\;"#, &[r#"\|\&\;"#]),
|
||||
(r#"\\<\\>"#, &[r#"\<\>"#]),
|
||||
(r#"\\(\\)"#, &[r#"\(\)"#]),
|
||||
(r#"\$"#, &[r#"$"#]),
|
||||
(r"\\|\\&\\;", &[r"\|\&\;"]),
|
||||
(r"\\<\\>", &[r"\<\>"]),
|
||||
(r"\\(\\)", &[r"\(\)"]),
|
||||
(r"\$", &[r"$"]),
|
||||
(r#"\""#, &[r#"""#]),
|
||||
(r#"\'"#, &[r#"'"#]),
|
||||
(r"\'", &[r"'"]),
|
||||
("\\\n", &[]),
|
||||
(" \\\n \n", &[]),
|
||||
("a\nb\nc", &["a", "b", "c"]),
|
||||
@@ -1179,7 +1180,7 @@ mod tests_split_iterator {
|
||||
Err(ParseError::InvalidSequenceBackslashXInMinusS { pos: 2, c: 'a' })
|
||||
);
|
||||
assert_eq!(
|
||||
split(r#"\🦉"#),
|
||||
split(r"\🦉"),
|
||||
Err(ParseError::InvalidSequenceBackslashXInMinusS {
|
||||
pos: 1,
|
||||
c: '\u{FFFD}'
|
||||
@@ -1190,9 +1191,9 @@ mod tests_split_iterator {
|
||||
#[test]
|
||||
fn split_comments() {
|
||||
split_ok(&[
|
||||
(r#" x # comment "#, &["x"]),
|
||||
(r#" w1#w2 "#, &["w1#w2"]),
|
||||
(r#"'not really a # comment'"#, &["not really a # comment"]),
|
||||
(r" x # comment ", &["x"]),
|
||||
(r" w1#w2 ", &["w1#w2"]),
|
||||
(r"'not really a # comment'", &["not really a # comment"]),
|
||||
(" a # very long comment \n b # another comment", &["a", "b"]),
|
||||
]);
|
||||
}
|
||||
|
||||
+1062
-745
File diff suppressed because it is too large
Load Diff
@@ -16,11 +16,12 @@ fn test_invalid_arg() {
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[allow(unused_mut)]
|
||||
fn test_id_no_specified_user() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let result = ts.ucmd().run();
|
||||
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
||||
let mut _exp_stdout = exp_result.stdout_str().to_string();
|
||||
let mut exp_stdout = exp_result.stdout_str().to_string();
|
||||
|
||||
#[cfg(not(feature = "feat_selinux"))]
|
||||
{
|
||||
@@ -29,12 +30,12 @@ fn test_id_no_specified_user() {
|
||||
// uid=1001(runner) gid=121(docker) groups=121(docker),4(adm),101(systemd-journal) \
|
||||
// context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
|
||||
if let Some(context_offset) = exp_result.stdout_str().find(" context=") {
|
||||
_exp_stdout.replace_range(context_offset.._exp_stdout.len() - 1, "");
|
||||
exp_stdout.replace_range(context_offset..exp_stdout.len() - 1, "");
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
.stdout_is(_exp_stdout)
|
||||
.stdout_is(exp_stdout)
|
||||
.stderr_is(exp_result.stderr_str())
|
||||
.code_is(exp_result.code());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ fn test_kill_table_lists_all_vertically() {
|
||||
let signals = command
|
||||
.stdout_str()
|
||||
.split('\n')
|
||||
.flat_map(|line| line.trim().split(' ').nth(1))
|
||||
.filter_map(|line| line.trim().split(' ').nth(1))
|
||||
.collect::<Vec<&str>>();
|
||||
|
||||
assert!(signals.contains(&"KILL"));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
#![allow(clippy::similar_names)]
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs mdir COLORTERM mexe bcdef mfoo
|
||||
#![allow(
|
||||
clippy::similar_names,
|
||||
clippy::too_many_lines,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
|
||||
#[cfg(any(unix, feature = "feat_selinux"))]
|
||||
use crate::common::util::expected_result;
|
||||
@@ -160,7 +165,7 @@ fn get_filesystem_type(scene: &TestScenario, path: &Path) -> String {
|
||||
let output = cmd.succeeds();
|
||||
let stdout_str = String::from_utf8_lossy(output.stdout());
|
||||
println!("output of stat call ({cmd:?}):\n{stdout_str}");
|
||||
let regex_str = r#"Filesystem\s+Type\s+.+[\r\n]+([^\s]+)\s+(?<fstype>[^\s]+)\s+"#;
|
||||
let regex_str = r"Filesystem\s+Type\s+.+[\r\n]+([^\s]+)\s+(?<fstype>[^\s]+)\s+";
|
||||
let regex = Regex::new(regex_str).unwrap();
|
||||
let m = regex.captures(&stdout_str).unwrap();
|
||||
let fstype = m["fstype"].to_owned();
|
||||
@@ -1150,6 +1155,7 @@ fn test_ls_long_padding_of_size_column_with_multiple_files() {
|
||||
#[cfg(all(feature = "ln", feature = "mkdir", feature = "touch"))]
|
||||
#[test]
|
||||
#[cfg(all(feature = "ln", feature = "mkdir", feature = "touch"))]
|
||||
#[allow(clippy::items_after_statements)]
|
||||
fn test_ls_long_symlink_color() {
|
||||
// If you break this test after breaking mkdir, touch, or ln, do not be alarmed!
|
||||
// This test is made for ls, but it attempts to run those utils in the process.
|
||||
@@ -1378,7 +1384,7 @@ fn test_ls_long_symlink_color() {
|
||||
|
||||
/// This test is for "ls -l --color=auto|--color=always"
|
||||
/// We use "--color=always" as the colors are the same regardless of the color option being "auto" or "always"
|
||||
/// tests whether the specific color of the target and the dangling_symlink are equal and checks
|
||||
/// tests whether the specific color of the target and the `dangling_symlink` are equal and checks
|
||||
/// whether checks whether ls outputs the correct path for the symlink and the file it points to and applies the color code to it.
|
||||
#[test]
|
||||
fn test_ls_long_dangling_symlink_color() {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
#![allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
use libc::mode_t;
|
||||
|
||||
@@ -560,8 +560,8 @@ fn test_dec_offset() {
|
||||
|
||||
#[test]
|
||||
fn test_no_offset() {
|
||||
let input = [0u8; 31];
|
||||
const LINE: &str = " 00000000 00000000 00000000 00000000\n";
|
||||
let input = [0u8; 31];
|
||||
let expected_output = [LINE, LINE, LINE, LINE].join("");
|
||||
|
||||
new_ucmd!()
|
||||
|
||||
@@ -167,9 +167,9 @@ fn test_delimiter_list_ending_with_escaped_backslash() {
|
||||
for d in ["-d", "--delimiters"] {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut ins = vec![];
|
||||
for (i, _in) in ["a\n", "b\n"].iter().enumerate() {
|
||||
for (i, one_in) in ["a\n", "b\n"].iter().enumerate() {
|
||||
let file = format!("in{}", i);
|
||||
at.write(&file, _in);
|
||||
at.write(&file, one_in);
|
||||
ins.push(file);
|
||||
}
|
||||
ucmd.args(&[d, "\\\\"])
|
||||
@@ -198,9 +198,9 @@ fn test_data() {
|
||||
for example in EXAMPLE_DATA {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut ins = vec![];
|
||||
for (i, _in) in example.ins.iter().enumerate() {
|
||||
for (i, one_in) in example.ins.iter().enumerate() {
|
||||
let file = format!("in{i}");
|
||||
at.write(&file, _in);
|
||||
at.write(&file, one_in);
|
||||
ins.push(file);
|
||||
}
|
||||
println!("{}", example.name);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
#![allow(clippy::stable_sort_primitive)]
|
||||
|
||||
use std::process::Stdio;
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
|
||||
@@ -106,7 +106,7 @@ fn test_very_large_range() {
|
||||
.collect();
|
||||
assert_eq!(result_seq.len(), num_samples, "Miscounted output length!");
|
||||
assert!(
|
||||
result_seq.iter().all(|x| (0..=1234567890).contains(x)),
|
||||
result_seq.iter().all(|x| (0..=1_234_567_890).contains(x)),
|
||||
"Output includes element not from range: {}",
|
||||
result.stdout_str()
|
||||
);
|
||||
@@ -132,7 +132,7 @@ fn test_very_large_range_offset() {
|
||||
assert!(
|
||||
result_seq
|
||||
.iter()
|
||||
.all(|x| (1234567890..=2147483647).contains(x)),
|
||||
.all(|x| (1_234_567_890..=2_147_483_647).contains(x)),
|
||||
"Output includes element not from range: {}",
|
||||
result.stdout_str()
|
||||
);
|
||||
@@ -234,7 +234,13 @@ fn test_range_permute_no_overflow_0_max() {
|
||||
#[test]
|
||||
fn test_very_high_range_full() {
|
||||
let input_seq = vec![
|
||||
2147483641, 2147483642, 2147483643, 2147483644, 2147483645, 2147483646, 2147483647,
|
||||
2_147_483_641,
|
||||
2_147_483_642,
|
||||
2_147_483_643,
|
||||
2_147_483_644,
|
||||
2_147_483_645,
|
||||
2_147_483_646,
|
||||
2_147_483_647,
|
||||
];
|
||||
let result = new_ucmd!().arg("-i2147483641-2147483647").succeeds();
|
||||
result.no_stderr();
|
||||
@@ -320,7 +326,7 @@ fn test_echo_multi() {
|
||||
.stdout_str()
|
||||
.split('\n')
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|x| x.into())
|
||||
.map(std::convert::Into::into)
|
||||
.collect();
|
||||
result_seq.sort_unstable();
|
||||
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
|
||||
@@ -335,7 +341,7 @@ fn test_echo_postfix() {
|
||||
.stdout_str()
|
||||
.split('\n')
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|x| x.into())
|
||||
.map(std::convert::Into::into)
|
||||
.collect();
|
||||
result_seq.sort_unstable();
|
||||
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user