mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
ls: bring up to date with recent changes
This commit is contained in:
parent
cd1514bd57
commit
b9f4964a96
4 changed files with 14 additions and 15 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1412,9 +1412,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.69"
|
version = "1.0.70"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb"
|
checksum = "b9505f307c872bab8eb46f77ae357c8eba1fdacead58ee5a850116b1d7f82883"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote 1.0.9",
|
"quote 1.0.9",
|
||||||
|
@ -2007,6 +2007,7 @@ dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"clap",
|
"clap",
|
||||||
"globset",
|
"globset",
|
||||||
|
"lazy_static",
|
||||||
"lscolors",
|
"lscolors",
|
||||||
"number_prefix",
|
"number_prefix",
|
||||||
"term_grid",
|
"term_grid",
|
||||||
|
|
|
@ -26,6 +26,9 @@ uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["
|
||||||
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "ls"
|
name = "ls"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
mod quoting_style;
|
mod quoting_style;
|
||||||
mod version_cmp;
|
mod version_cmp;
|
||||||
|
@ -18,12 +21,11 @@ use globset::{self, Glob, GlobSet, GlobSetBuilder};
|
||||||
use lscolors::LsColors;
|
use lscolors::LsColors;
|
||||||
use number_prefix::NumberPrefix;
|
use number_prefix::NumberPrefix;
|
||||||
use quoting_style::{escape_name, QuotingStyle};
|
use quoting_style::{escape_name, QuotingStyle};
|
||||||
use std::fs;
|
|
||||||
use std::fs::{DirEntry, FileType, Metadata};
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::FileTypeExt;
|
use std::collections::HashMap;
|
||||||
|
use std::fs::{self, DirEntry, FileType, Metadata};
|
||||||
#[cfg(any(unix, target_os = "redox"))]
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::{FileTypeExt, MetadataExt};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::fs::MetadataExt;
|
use std::os::windows::fs::MetadataExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
|
@ -647,18 +647,14 @@ fn test_ls_color() {
|
||||||
at.touch(&nested_file);
|
at.touch(&nested_file);
|
||||||
at.touch("test-color");
|
at.touch("test-color");
|
||||||
|
|
||||||
at.symlink_file(&nested_file, "link");
|
|
||||||
|
|
||||||
let a_with_colors = "\x1b[1;34ma\x1b[0m";
|
let a_with_colors = "\x1b[1;34ma\x1b[0m";
|
||||||
let z_with_colors = "\x1b[1;34mz\x1b[0m";
|
let z_with_colors = "\x1b[1;34mz\x1b[0m";
|
||||||
let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m";
|
let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m";
|
||||||
let link_with_color = "\x1b[1;36mlink\x1b[0m";
|
|
||||||
|
|
||||||
// Color is disabled by default
|
// Color is disabled by default
|
||||||
let result = scene.ucmd().succeeds();
|
let result = scene.ucmd().succeeds();
|
||||||
assert!(!result.stdout_str().contains(a_with_colors));
|
assert!(!result.stdout_str().contains(a_with_colors));
|
||||||
assert!(!result.stdout_str().contains(z_with_colors));
|
assert!(!result.stdout_str().contains(z_with_colors));
|
||||||
assert!(!result.stdout_str().contains(link_with_color));
|
|
||||||
|
|
||||||
// Color should be enabled
|
// Color should be enabled
|
||||||
scene
|
scene
|
||||||
|
@ -666,8 +662,7 @@ fn test_ls_color() {
|
||||||
.arg("--color")
|
.arg("--color")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains(a_with_colors)
|
.stdout_contains(a_with_colors)
|
||||||
.stdout_contains(z_with_colors)
|
.stdout_contains(z_with_colors);
|
||||||
.stdout_contains(link_with_color);
|
|
||||||
|
|
||||||
// Color should be enabled
|
// Color should be enabled
|
||||||
scene
|
scene
|
||||||
|
@ -675,14 +670,12 @@ fn test_ls_color() {
|
||||||
.arg("--color=always")
|
.arg("--color=always")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains(a_with_colors)
|
.stdout_contains(a_with_colors)
|
||||||
.stdout_contains(z_with_colors)
|
.stdout_contains(z_with_colors);
|
||||||
.stdout_contains(link_with_color);
|
|
||||||
|
|
||||||
// Color should be disabled
|
// Color should be disabled
|
||||||
let result = scene.ucmd().arg("--color=never").succeeds();
|
let result = scene.ucmd().arg("--color=never").succeeds();
|
||||||
assert!(!result.stdout_str().contains(a_with_colors));
|
assert!(!result.stdout_str().contains(a_with_colors));
|
||||||
assert!(!result.stdout_str().contains(z_with_colors));
|
assert!(!result.stdout_str().contains(z_with_colors));
|
||||||
assert!(!result.stdout_str().contains(link_with_color));
|
|
||||||
|
|
||||||
// Nested dir should be shown and colored
|
// Nested dir should be shown and colored
|
||||||
scene
|
scene
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue