Skip to content

Commit ab3f4fb

Browse files
committed
test GlobError accessor methods
This also adds more explicit tests for the generated error.
1 parent d9c32e1 commit ab3f4fb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,24 @@ mod test {
899899
assert!(glob("abc[def").err().unwrap().pos == 3);
900900
}
901901

902+
// this test assumes that there is a /root directory and that
903+
// the user running this test is not root or otherwise doesn't
904+
// have permission to read its contents
902905
#[cfg(unix)]
903906
#[test]
904907
fn test_iteration_errors() {
905908
let mut iter = glob("/root/*").unwrap();
909+
910+
// GlobErrors shouldn't halt iteration
906911
let next = iter.next();
907912
assert!(next.is_some());
908-
assert!(next.unwrap().is_err());
913+
914+
let err = next.unwrap();
915+
assert!(err.is_err());
916+
917+
let err = err.unwrap_err();
918+
assert!(*err.path() == Path::new("/root"));
919+
assert!(err.error().kind == ::std::io::IoErrorKind::PermissionDenied);
909920
}
910921

911922
#[test]

0 commit comments

Comments
 (0)