Skip to content

Commit aacd6d4

Browse files
authored
Merge pull request #7816 from drinkcat/test_ls_more_acl
test_ls: Improve acl test
2 parents c40856f + adb23b1 commit aacd6d4

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/by-util/test_ls.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs mdir COLORTERM mexe bcdef mfoo
6-
// spell-checker:ignore (words) fakeroot setcap
6+
// spell-checker:ignore (words) fakeroot setcap drwxr
77
#![allow(
88
clippy::similar_names,
99
clippy::too_many_lines,
@@ -5317,14 +5317,15 @@ fn test_acl_display() {
53175317

53185318
let scene = TestScenario::new(util_name!());
53195319
let at = &scene.fixtures;
5320-
let path = "a42";
5321-
at.mkdir(path);
53225320

5323-
let path = at.plus_as_string(path);
5321+
at.mkdir("with_acl");
5322+
let path_with_acl = at.plus_as_string("with_acl");
5323+
at.mkdir("without_acl");
5324+
53245325
// calling the command directly. xattr requires some dev packages to be installed
53255326
// and it adds a complex dependency just for a test
53265327
match Command::new("setfacl")
5327-
.args(["-d", "-m", "group::rwx", &path])
5328+
.args(["-d", "-m", "group::rwx", &path_with_acl])
53285329
.status()
53295330
.map(|status| status.code())
53305331
{
@@ -5339,11 +5340,19 @@ fn test_acl_display() {
53395340
}
53405341
}
53415342

5343+
// Expected output (we just look for `+` presence and absence in the first column):
5344+
// ...
5345+
// drwxr-xr-x+ 2 user group 40 Apr 21 12:44 with_acl
5346+
// drwxr-xr-x 2 user group 40 Apr 21 12:44 without_acl
5347+
let re_with_acl = Regex::new(r"[a-z-]*\+ .*with_acl").unwrap();
5348+
let re_without_acl = Regex::new(r"[a-z-]* .*without_acl").unwrap();
5349+
53425350
scene
53435351
.ucmd()
5344-
.args(&["-lda", &path])
5352+
.args(&["-la", &at.as_string()])
53455353
.succeeds()
5346-
.stdout_contains("+");
5354+
.stdout_matches(&re_with_acl)
5355+
.stdout_matches(&re_without_acl);
53475356
}
53485357

53495358
// Make sure that "ls --color" correctly applies color "normal" to text and

0 commit comments

Comments
 (0)