mirror of
https://github.com/nushell/nushell
synced 2024-12-25 12:33:17 +00:00
skip test_iteration_errors
if /root
is missing (#14299)
# Description `test_iteration_errors` no longer requires `/root` to exist: ``` failures: ---- test::test_iteration_errors stdout ---- thread 'test::test_iteration_errors' panicked at crates/nu-glob/src/li b.rs:1151:13: assertion failed: next.is_some() ``` `/root` is an optional home directory in the [File Hierarchy Standard][1]. I encountered this while running the tests in a `guix shell` container, which doesn't include a root user. [1]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s14.html # User-Facing Changes None
This commit is contained in:
parent
948205c8e6
commit
3893fbb0b1
1 changed files with 20 additions and 10 deletions
|
@ -1144,18 +1144,28 @@ mod test {
|
|||
use std::io;
|
||||
let mut iter = glob("/root/*").unwrap();
|
||||
|
||||
// Skip test if running with permissions to read /root
|
||||
if std::fs::read_dir("/root/").is_err() {
|
||||
// GlobErrors shouldn't halt iteration
|
||||
let next = iter.next();
|
||||
assert!(next.is_some());
|
||||
match std::fs::read_dir("/root/") {
|
||||
// skip if running with permissions to read /root
|
||||
Ok(_) => {}
|
||||
|
||||
let err = next.unwrap();
|
||||
assert!(err.is_err());
|
||||
// skip if /root doesn't exist
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||
assert!(iter.count() == 0);
|
||||
}
|
||||
|
||||
let err = err.err().unwrap();
|
||||
assert!(err.path() == Path::new("/root"));
|
||||
assert!(err.error().kind() == io::ErrorKind::PermissionDenied);
|
||||
// should otherwise return a single match with permission error
|
||||
Err(_) => {
|
||||
// GlobErrors shouldn't halt iteration
|
||||
let next = iter.next();
|
||||
assert!(next.is_some());
|
||||
|
||||
let err = next.unwrap();
|
||||
assert!(err.is_err());
|
||||
|
||||
let err = err.err().unwrap();
|
||||
assert!(err.path() == Path::new("/root"));
|
||||
assert!(err.error().kind() == io::ErrorKind::PermissionDenied);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue