mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01: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
@ -1144,18 +1144,28 @@ mod test {
|
|||||||
use std::io;
|
use std::io;
|
||||||
let mut iter = glob("/root/*").unwrap();
|
let mut iter = glob("/root/*").unwrap();
|
||||||
|
|
||||||
// Skip test if running with permissions to read /root
|
match std::fs::read_dir("/root/") {
|
||||||
if std::fs::read_dir("/root/").is_err() {
|
// skip if running with permissions to read /root
|
||||||
// GlobErrors shouldn't halt iteration
|
Ok(_) => {}
|
||||||
let next = iter.next();
|
|
||||||
assert!(next.is_some());
|
|
||||||
|
|
||||||
let err = next.unwrap();
|
// skip if /root doesn't exist
|
||||||
assert!(err.is_err());
|
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||||
|
assert!(iter.count() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
let err = err.err().unwrap();
|
// should otherwise return a single match with permission error
|
||||||
assert!(err.path() == Path::new("/root"));
|
Err(_) => {
|
||||||
assert!(err.error().kind() == io::ErrorKind::PermissionDenied);
|
// 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 New Issue
Block a user