diff options
author | Elliott Hughes <enh@google.com> | 2021-04-02 10:50:05 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2021-04-02 10:50:05 -0700 |
commit | d7bcf437866b7142b68207bb7ac480dfe63ab990 (patch) | |
tree | cc218f809b980499efdc11c0902cd6c3b2637ab4 /tests/basic.rs | |
parent | eaca4d18d27d7fa54182f1cd91849bddca42db92 (diff) | |
download | which-d7bcf437866b7142b68207bb7ac480dfe63ab990.tar.gz |
Upgrade rust/crates/which to 4.1.0android-s-beta-2android-s-beta-1
Test: make
Change-Id: I7f3f322721f4e003735ea1147bec93355b0a4b32
Diffstat (limited to 'tests/basic.rs')
-rw-r--r-- | tests/basic.rs | 30 |
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(); |