mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
Merge pull request #2099 from tertsdiepraam/ls/cross_platform_colors
ls: cross-platform colors
This commit is contained in:
commit
46b95fb8bd
4 changed files with 124 additions and 208 deletions
|
@ -629,20 +629,27 @@ fn test_ls_recursive() {
|
|||
result.stdout_contains(&"a\\b:\nb");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_ls_ls_color() {
|
||||
fn test_ls_color() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.mkdir("a");
|
||||
at.mkdir("a/nested_dir");
|
||||
let nested_dir = Path::new("a")
|
||||
.join("nested_dir")
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
at.mkdir(&nested_dir);
|
||||
at.mkdir("z");
|
||||
at.touch(&at.plus_as_string("a/nested_file"));
|
||||
let nested_file = Path::new("a")
|
||||
.join("nested_file")
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
at.touch(&nested_file);
|
||||
at.touch("test-color");
|
||||
|
||||
let a_with_colors = "\x1b[01;34ma\x1b[0m";
|
||||
let z_with_colors = "\x1b[01;34mz\x1b[0m";
|
||||
let nested_dir_with_colors = "\x1b[01;34mnested_dir\x1b[0m";
|
||||
let a_with_colors = "\x1b[1;34ma\x1b[0m";
|
||||
let z_with_colors = "\x1b[1;34mz\x1b[0m";
|
||||
let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m";
|
||||
|
||||
// Color is disabled by default
|
||||
let result = scene.ucmd().succeeds();
|
||||
|
@ -678,14 +685,6 @@ fn test_ls_ls_color() {
|
|||
.succeeds()
|
||||
.stdout_contains(nested_dir_with_colors);
|
||||
|
||||
// Color has no effect
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--color=always")
|
||||
.arg("a/nested_file")
|
||||
.succeeds()
|
||||
.stdout_contains("a/nested_file\n");
|
||||
|
||||
// No output
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -825,7 +824,7 @@ fn test_ls_indicator_style() {
|
|||
let options = vec!["classify", "file-type", "slash"];
|
||||
for opt in options {
|
||||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
let result = scene
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.succeeds()
|
||||
|
@ -835,7 +834,7 @@ fn test_ls_indicator_style() {
|
|||
// Same test as above, but with the alternate flags.
|
||||
let options = vec!["--classify", "--file-type", "-p"];
|
||||
for opt in options {
|
||||
let result = scene
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}", opt))
|
||||
.succeeds()
|
||||
|
@ -846,7 +845,7 @@ fn test_ls_indicator_style() {
|
|||
let options = vec!["classify", "file-type"];
|
||||
for opt in options {
|
||||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
let result = scene
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.succeeds()
|
||||
|
@ -970,7 +969,7 @@ fn test_ls_hidden_windows() {
|
|||
|
||||
let result = scene.ucmd().succeeds();
|
||||
assert!(!result.stdout_str().contains(file));
|
||||
let result = scene.ucmd().arg("-a").succeeds().stdout_contains(file);
|
||||
scene.ucmd().arg("-a").succeeds().stdout_contains(file);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue