Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ls: gnu test case color-ext fix #6537

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ hostname = "0.4"
indicatif = "0.17.8"
itertools = "0.13.0"
libc = "0.2.153"
lscolors = { version = "0.18.0", default-features = false, features = [
lscolors = { version = "0.19.0", default-features = false, features = [
"gnu_legacy",
] }
memchr = "2.7.2"
Expand Down
108 changes: 108 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4950,3 +4950,111 @@ fn test_ls_color_clear_to_eol() {
// cspell:disable-next-line
result.stdout_contains("\x1b[0m\x1b[31;42mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.foo\x1b[0m\x1b[K");
}

#[test]
fn test_suffix_case_sensitivity() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("img1.jpg");
at.touch("IMG2.JPG");
at.touch("img3.JpG");
at.touch("file1.z");
at.touch("file2.Z");

// *.jpg is specified only once so any suffix that has .jpg should match
// without caring about the letter case
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.Z=01;31")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("file1.z")
.arg("file2.Z")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35mIMG2.JPG\x1b[0m\n\
\x1b[01;31mfile1.z\x1b[0m\n\
\x1b[01;31mfile2.Z\x1b[0m",
/* cSpell:enable */
);

// *.jpg is specified more than once with different cases and style, so
// case should matter here
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
img3.JpG",
/* cSpell:enable */
);

// *.jpg is specified more than once with different cases but style is same, so
// case can ignored
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.JPG=01;35")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35mIMG2.JPG\x1b[0m\n\
\x1b[01;35mimg3.JpG\x1b[0m",
/* cSpell:enable */
);

// last *.jpg gets more priority resulting in same style across
// different cases specified, so case can ignored
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.jpg=01;35;46:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35;46mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
\x1b[01;35;46mimg3.JpG\x1b[0m",
/* cSpell:enable */
);

// last *.jpg gets more priority resulting in different style across
// different cases specified, so case matters
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35;46:*.jpg=01;35:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
img3.JpG",
/* cSpell:enable */
);
}
Loading