Skip to content

Commit adb23b1

Browse files
committed
test_ls: Improve acl test
Create a file with some ACL, and another without, and check that `+` only appears on the file with ACL.
1 parent b5e0e23 commit adb23b1

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,
@@ -5313,14 +5313,15 @@ fn test_acl_display() {
53135313

53145314
let scene = TestScenario::new(util_name!());
53155315
let at = &scene.fixtures;
5316-
let path = "a42";
5317-
at.mkdir(path);
53185316

5319-
let path = at.plus_as_string(path);
5317+
at.mkdir("with_acl");
5318+
let path_with_acl = at.plus_as_string("with_acl");
5319+
at.mkdir("without_acl");
5320+
53205321
// calling the command directly. xattr requires some dev packages to be installed
53215322
// and it adds a complex dependency just for a test
53225323
match Command::new("setfacl")
5323-
.args(["-d", "-m", "group::rwx", &path])
5324+
.args(["-d", "-m", "group::rwx", &path_with_acl])
53245325
.status()
53255326
.map(|status| status.code())
53265327
{
@@ -5335,11 +5336,19 @@ fn test_acl_display() {
53355336
}
53365337
}
53375338

5339+
// Expected output (we just look for `+` presence and absence in the first column):
5340+
// ...
5341+
// drwxr-xr-x+ 2 user group 40 Apr 21 12:44 with_acl
5342+
// drwxr-xr-x 2 user group 40 Apr 21 12:44 without_acl
5343+
let re_with_acl = Regex::new(r"[a-z-]*\+ .*with_acl").unwrap();
5344+
let re_without_acl = Regex::new(r"[a-z-]* .*without_acl").unwrap();
5345+
53385346
scene
53395347
.ucmd()
5340-
.args(&["-lda", &path])
5348+
.args(&["-la", &at.as_string()])
53415349
.succeeds()
5342-
.stdout_contains("+");
5350+
.stdout_matches(&re_with_acl)
5351+
.stdout_matches(&re_without_acl);
53435352
}
53445353

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

0 commit comments

Comments
 (0)