mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ls: compile regexes outside of loop in tests
This commit is contained in:
parent
c872cfa5d1
commit
e777db9304
1 changed files with 31 additions and 21 deletions
|
@ -1096,13 +1096,16 @@ fn test_ls_long() {
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
at.touch(at.plus_as_string("test-long"));
|
at.touch(at.plus_as_string("test-long"));
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
let regex = r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*";
|
||||||
|
#[cfg(windows)]
|
||||||
|
let regex = r"[-dl](r[w-]x){3}.*";
|
||||||
|
|
||||||
|
let re = &Regex::new(regex).unwrap();
|
||||||
|
|
||||||
for arg in LONG_ARGS {
|
for arg in LONG_ARGS {
|
||||||
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
|
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
|
||||||
#[cfg(not(windows))]
|
result.stdout_matches(re);
|
||||||
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
result.stdout_matches(&Regex::new(r"[-dl](r[w-]x){3}.*").unwrap());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1118,6 @@ fn test_ls_long_format() {
|
||||||
at.touch(at.plus_as_string("test-long-dir/test-long-file"));
|
at.touch(at.plus_as_string("test-long-dir/test-long-file"));
|
||||||
at.mkdir(at.plus_as_string("test-long-dir/test-long-dir"));
|
at.mkdir(at.plus_as_string("test-long-dir/test-long-dir"));
|
||||||
|
|
||||||
for arg in LONG_ARGS {
|
|
||||||
// Assuming sane username do not have spaces within them.
|
// Assuming sane username do not have spaces within them.
|
||||||
// A line of the output should be:
|
// A line of the output should be:
|
||||||
// One of the characters -bcCdDlMnpPsStTx?
|
// One of the characters -bcCdDlMnpPsStTx?
|
||||||
|
@ -1129,9 +1131,17 @@ fn test_ls_long_format() {
|
||||||
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
|
// Either a year or a time, currently [0-9:]+, preceded by column whitespace,
|
||||||
// and followed by a single space.
|
// and followed by a single space.
|
||||||
// Whatever comes after is irrelevant to this specific test.
|
// Whatever comes after is irrelevant to this specific test.
|
||||||
scene.ucmd().arg(arg).arg("test-long-dir").succeeds().stdout_matches(&Regex::new(
|
let re = &Regex::new(
|
||||||
r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}\.? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ "
|
r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}\.? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ "
|
||||||
).unwrap());
|
).unwrap();
|
||||||
|
|
||||||
|
for arg in LONG_ARGS {
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg(arg)
|
||||||
|
.arg("test-long-dir")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(re);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This checks for the line with the .. entry. The uname and group should be digits.
|
// This checks for the line with the .. entry. The uname and group should be digits.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue