Allow for test_iteration_errors to work when run as root (#5609)

* allow for test_iteration_errors to work when run as root

* Add comment to skip condition

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
pwygab 2022-05-22 17:47:03 +08:00 committed by GitHub
parent 1e89cc3578
commit 5bc9246f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -936,16 +936,19 @@ mod test {
use std::io; use std::io;
let mut iter = glob("/root/*").unwrap(); let mut iter = glob("/root/*").unwrap();
// GlobErrors shouldn't halt iteration // Skip test if running with permissions to read /root
let next = iter.next(); if std::fs::read_dir("/root/").is_err() {
assert!(next.is_some()); // GlobErrors shouldn't halt iteration
let next = iter.next();
assert!(next.is_some());
let err = next.unwrap(); let err = next.unwrap();
assert!(err.is_err()); assert!(err.is_err());
let err = err.err().unwrap(); let err = err.err().unwrap();
assert!(err.path() == Path::new("/root")); assert!(err.path() == Path::new("/root"));
assert!(err.error().kind() == io::ErrorKind::PermissionDenied); assert!(err.error().kind() == io::ErrorKind::PermissionDenied);
}
} }
#[test] #[test]