aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic.rs')
-rw-r--r--tests/basic.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/basic.rs b/tests/basic.rs
index 24a700d..7cb7a08 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -87,6 +87,13 @@ fn _which<T: AsRef<OsStr>>(f: &TestFixture, path: T) -> which::Result<which::Can
which::CanonicalPath::new_in(path, Some(f.paths.clone()), f.tempdir.path())
}
+fn _which_all<T: AsRef<OsStr>>(
+ f: &TestFixture,
+ path: T,
+) -> which::Result<impl Iterator<Item = which::Result<which::CanonicalPath>>> {
+ which::CanonicalPath::all_in(path, Some(f.paths.clone()), f.tempdir.path().to_path_buf())
+}
+
#[test]
#[cfg(unix)]
fn it_works() {
@@ -148,6 +155,29 @@ fn test_which_second() {
}
#[test]
+fn test_which_all() {
+ let f = TestFixture::new();
+ let actual = _which_all(&f, BIN_NAME)
+ .unwrap()
+ .map(|c| c.unwrap())
+ .collect::<Vec<_>>();
+ let mut expected = f
+ .bins
+ .iter()
+ .map(|p| p.canonicalize().unwrap())
+ .collect::<Vec<_>>();
+ #[cfg(windows)]
+ {
+ expected.retain(|p| p.extension().map(|ext| ext == "exe" || ext == "cmd") == Some(true));
+ }
+ #[cfg(not(windows))]
+ {
+ expected.retain(|p| p.file_name().unwrap() == BIN_NAME);
+ }
+ assert_eq!(actual, expected);
+}
+
+#[test]
#[cfg(unix)]
fn test_which_absolute() {
let f = TestFixture::new();