mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
Merge pull request #2633 from blyxxyz/update-quoting
Update filename quoting and printing
This commit is contained in:
commit
2170d81621
98 changed files with 849 additions and 616 deletions
|
@ -23,7 +23,7 @@ fn test_enter_chroot_fails() {
|
|||
|
||||
assert!(result
|
||||
.stderr_str()
|
||||
.starts_with("chroot: cannot chroot to jail: Operation not permitted (os error 1)"));
|
||||
.starts_with("chroot: cannot chroot to 'jail': Operation not permitted (os error 1)"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -34,7 +34,7 @@ fn test_no_such_directory() {
|
|||
|
||||
ucmd.arg("a")
|
||||
.fails()
|
||||
.stderr_is("chroot: cannot change root directory to `a`: no such directory");
|
||||
.stderr_is("chroot: cannot change root directory to 'a': no such directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -68,7 +68,7 @@ fn test_invalid_file() {
|
|||
.arg(folder_name)
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: 'asdf' No such file or directory");
|
||||
.stderr_contains("cksum: asdf: No such file or directory");
|
||||
|
||||
// Then check when the file is of an invalid type
|
||||
at.mkdir(folder_name);
|
||||
|
@ -76,7 +76,7 @@ fn test_invalid_file() {
|
|||
.arg(folder_name)
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: 'asdf' Is a directory");
|
||||
.stderr_contains("cksum: asdf: Is a directory");
|
||||
}
|
||||
|
||||
// Make sure crc is correct for files larger than 32 bytes
|
||||
|
|
|
@ -432,10 +432,7 @@ fn test_ls_long_symlink_color() {
|
|||
let mut result_lines = result
|
||||
.stdout_str()
|
||||
.lines()
|
||||
.filter_map(|line| match line.starts_with("lrwx") {
|
||||
true => Some(line),
|
||||
false => None,
|
||||
})
|
||||
.filter(|line| line.starts_with("lrwx"))
|
||||
.enumerate();
|
||||
|
||||
// For each enumerated line, we assert that the output of ls matches the expected output.
|
||||
|
@ -455,14 +452,12 @@ fn test_ls_long_symlink_color() {
|
|||
|
||||
// We look up the Colors that are expected in `colors` using the ColorReferences
|
||||
// stored in `expected_output`.
|
||||
let expected_name_color = match expected_output[i].0 {
|
||||
Some(color_reference) => Some(colors[color_reference[0]][color_reference[1]].as_str()),
|
||||
None => None,
|
||||
};
|
||||
let expected_target_color = match expected_output[i].2 {
|
||||
Some(color_reference) => Some(colors[color_reference[0]][color_reference[1]].as_str()),
|
||||
None => None,
|
||||
};
|
||||
let expected_name_color = expected_output[i]
|
||||
.0
|
||||
.map(|color_reference| colors[color_reference[0]][color_reference[1]].as_str());
|
||||
let expected_target_color = expected_output[i]
|
||||
.2
|
||||
.map(|color_reference| colors[color_reference[0]][color_reference[1]].as_str());
|
||||
|
||||
// This is the important part. The asserts inside assert_names_and_colors_are_equal
|
||||
// will panic if the colors or names do not match the expected colors or names.
|
||||
|
@ -470,11 +465,11 @@ fn test_ls_long_symlink_color() {
|
|||
// don't expect any color here, as in `expected_output[2], or don't know what specific
|
||||
// color to expect yet, as in expected_output[0:1].
|
||||
assert_names_and_colors_are_equal(
|
||||
&matched_name_color,
|
||||
matched_name_color,
|
||||
expected_name_color,
|
||||
&matched_name,
|
||||
expected_output[i].1,
|
||||
&matched_target_color,
|
||||
matched_target_color,
|
||||
expected_target_color,
|
||||
&matched_target,
|
||||
expected_output[i].3,
|
||||
|
@ -505,6 +500,7 @@ fn test_ls_long_symlink_color() {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn assert_names_and_colors_are_equal(
|
||||
name_color: &str,
|
||||
expected_name_color: Option<&str>,
|
||||
|
@ -530,7 +526,7 @@ fn test_ls_long_symlink_color() {
|
|||
|
||||
fn capture_colored_string(input: &str) -> (Color, Name) {
|
||||
let colored_name = Regex::new(r"\x1b\[([0-9;]+)m(.+)\x1b\[0m").unwrap();
|
||||
match colored_name.captures(&input) {
|
||||
match colored_name.captures(input) {
|
||||
Some(captures) => (
|
||||
captures.get(1).unwrap().as_str().to_string(),
|
||||
captures.get(2).unwrap().as_str().to_string(),
|
||||
|
|
|
@ -531,7 +531,7 @@ fn test_keys_invalid_field() {
|
|||
new_ucmd!()
|
||||
.args(&["-k", "1."])
|
||||
.fails()
|
||||
.stderr_only("sort: failed to parse key `1.`: failed to parse character index ``: cannot parse integer from empty string");
|
||||
.stderr_only("sort: failed to parse key '1.': failed to parse character index '': cannot parse integer from empty string");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -539,7 +539,7 @@ fn test_keys_invalid_field_option() {
|
|||
new_ucmd!()
|
||||
.args(&["-k", "1.1x"])
|
||||
.fails()
|
||||
.stderr_only("sort: failed to parse key `1.1x`: invalid option: `x`");
|
||||
.stderr_only("sort: failed to parse key '1.1x': invalid option: 'x'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -547,7 +547,7 @@ fn test_keys_invalid_field_zero() {
|
|||
new_ucmd!()
|
||||
.args(&["-k", "0.1"])
|
||||
.fails()
|
||||
.stderr_only("sort: failed to parse key `0.1`: field index can not be 0");
|
||||
.stderr_only("sort: failed to parse key '0.1': field index can not be 0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -555,7 +555,7 @@ fn test_keys_invalid_char_zero() {
|
|||
new_ucmd!()
|
||||
.args(&["-k", "1.0"])
|
||||
.fails()
|
||||
.stderr_only("sort: failed to parse key `1.0`: invalid character index 0 for the start position of a field");
|
||||
.stderr_only("sort: failed to parse key '1.0': invalid character index 0 for the start position of a field");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -59,7 +59,7 @@ fn test_invalid_file() {
|
|||
|
||||
at.mkdir("a");
|
||||
|
||||
ucmd.arg("a").fails().stderr_is("sum: 'a' Is a directory");
|
||||
ucmd.arg("a").fails().stderr_is("sum: a: Is a directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -68,5 +68,5 @@ fn test_invalid_metadata() {
|
|||
|
||||
ucmd.arg("b")
|
||||
.fails()
|
||||
.stderr_is("sum: 'b' No such file or directory");
|
||||
.stderr_is("sum: b: No such file or directory");
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ fn test_invalid_utf8_integer_compare() {
|
|||
|
||||
cmd.run()
|
||||
.status_code(2)
|
||||
.stderr_is("test: invalid integer 'fo<66>o'");
|
||||
.stderr_is("test: invalid integer $'fo\\x80o'");
|
||||
|
||||
let mut cmd = new_ucmd!();
|
||||
cmd.raw.arg(arg);
|
||||
|
@ -328,7 +328,7 @@ fn test_invalid_utf8_integer_compare() {
|
|||
|
||||
cmd.run()
|
||||
.status_code(2)
|
||||
.stderr_is("test: invalid integer 'fo<66>o'");
|
||||
.stderr_is("test: invalid integer $'fo\\x80o'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue