diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/rust.yml | 6 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 14 | ||||
-rw-r--r-- | Cargo.toml.orig | 12 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | TEST_MAPPING | 6 | ||||
-rw-r--r-- | src/checker.rs | 4 | ||||
-rw-r--r-- | src/finder.rs | 5 | ||||
-rw-r--r-- | tests/basic.rs | 49 |
10 files changed, 61 insertions, 47 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 692ca11..4dbf890 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "8fbe34239c16af9cd253e36e9c2d3384f9b55f83" + "sha1": "ca9cc93b392fa1d0eb4eb2a60c74b3b3ecff03bb" }, "path_in_vcs": "" }
\ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index dd380d3..aa13ec5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,7 +28,7 @@ jobs: name: Clippy [Linter] strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Setup | Checkout @@ -46,7 +46,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --workspace --all-targets --all-features + args: --workspace --all-targets --all-features -- -Dwarnings # Ensure that the project could be successfully compiled cargo_check: @@ -75,7 +75,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] rust: [stable, nightly] steps: - name: Setup | Checkout @@ -23,7 +23,7 @@ rust_library { host_supported: true, crate_name: "which", cargo_env_compat: true, - cargo_pkg_version: "4.2.4", + cargo_pkg_version: "4.2.5", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -12,7 +12,7 @@ [package] edition = "2018" name = "which" -version = "4.2.4" +version = "4.2.5" authors = ["Harry Fei <tiziyuanfang@gmail.com>"] description = "A Rust equivalent of Unix command \"which\". Locate installed executable in cross platforms." documentation = "https://docs.rs/which/" @@ -24,15 +24,15 @@ repository = "https://github.com/harryfei/which-rs.git" [package.metadata.docs.rs] all-features = true [dependencies.either] -version = "1.6" +version = "1.6.1" [dependencies.libc] -version = "0.2.65" +version = "0.2.121" [dependencies.regex] -version = "1.5.4" +version = "1.5.5" optional = true -[dev-dependencies.tempdir] -version = "0.3.7" +[dev-dependencies.tempfile] +version = "3.3.0" [target."cfg(windows)".dependencies.lazy_static] -version = "1" +version = "1.4.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index ec31c55..dccbdb4 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "which" -version = "4.2.4" +version = "4.2.5" edition = "2018" authors = ["Harry Fei <tiziyuanfang@gmail.com>"] repository = "https://github.com/harryfei/which-rs.git" @@ -12,15 +12,15 @@ categories = ["os", "filesystem"] keywords = ["which", "which-rs", "unix", "command"] [dependencies] -either = "1.6" -libc = "0.2.65" -regex = { version = "1.5.4", optional = true } +either = "1.6.1" +libc = "0.2.121" +regex = { version = "1.5.5", optional = true } [target.'cfg(windows)'.dependencies] -lazy_static = "1" +lazy_static = "1.4.0" [dev-dependencies] -tempdir = "0.3.7" +tempfile = "3.3.0" [package.metadata.docs.rs] all-features = true @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/which/which-4.2.4.crate" + value: "https://static.crates.io/crates/which/which-4.2.5.crate" } - version: "4.2.4" + version: "4.2.5" license_type: NOTICE last_upgrade_date { year: 2022 - month: 3 - day: 1 + month: 4 + day: 18 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index e4ec3b3..96a0732 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -7,6 +7,9 @@ ], "presubmit": [ { + "name": "keystore2_legacy_blobs_test" + }, + { "name": "keystore2_test" }, { @@ -15,6 +18,9 @@ ], "presubmit-rust": [ { + "name": "keystore2_legacy_blobs_test" + }, + { "name": "keystore2_test" }, { diff --git a/src/checker.rs b/src/checker.rs index 62b78a2..0e92c6a 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -1,7 +1,5 @@ use crate::finder::Checker; #[cfg(unix)] -use libc; -#[cfg(unix)] use std::ffi::CString; use std::fs; #[cfg(unix)] @@ -20,7 +18,7 @@ impl Checker for ExecutableChecker { #[cfg(unix)] fn is_valid(&self, path: &Path) -> bool { CString::new(path.as_os_str().as_bytes()) - .and_then(|c| Ok(unsafe { libc::access(c.as_ptr(), libc::X_OK) == 0 })) + .map(|c| unsafe { libc::access(c.as_ptr(), libc::X_OK) == 0 }) .unwrap_or(false) } diff --git a/src/finder.rs b/src/finder.rs index 43b659d..9b64294 100644 --- a/src/finder.rs +++ b/src/finder.rs @@ -94,6 +94,9 @@ impl Finder { T: AsRef<OsStr>, { let p = paths.ok_or(Error::CannotFindBinaryPath)?; + // Collect needs to happen in order to not have to + // change the API to borrow on `paths`. + #[allow(clippy::needless_collect)] let paths: Vec<_> = env::split_paths(&p).collect(); let matching_re = paths @@ -169,7 +172,7 @@ impl Finder { }) // PATHEXT not being set or not being a proper Unicode string is exceedingly // improbable and would probably break Windows badly. Still, don't crash: - .unwrap_or(vec![]); + .unwrap_or_default(); } paths diff --git a/tests/basic.rs b/tests/basic.rs index 897e912..59c5fb0 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -1,14 +1,13 @@ -extern crate tempdir; extern crate which; -#[cfg(feature = "regex")] +#[cfg(all(unix, feature = "regex"))] use regex::Regex; use std::ffi::{OsStr, OsString}; use std::fs; use std::io; use std::path::{Path, PathBuf}; use std::{env, vec}; -use tempdir::TempDir; +use tempfile::TempDir; struct TestFixture { /// Temp directory. @@ -19,8 +18,8 @@ struct TestFixture { pub bins: Vec<PathBuf>, } -const SUBDIRS: &'static [&'static str] = &["a", "b", "c"]; -const BIN_NAME: &'static str = "bin"; +const SUBDIRS: &[&str] = &["a", "b", "c"]; +const BIN_NAME: &str = "bin"; #[cfg(unix)] fn mk_bin(dir: &Path, path: &str, extension: &str) -> io::Result<PathBuf> { @@ -55,7 +54,7 @@ impl TestFixture { // tmp/c/bin.exe // tmp/c/bin.cmd pub fn new() -> TestFixture { - let tempdir = TempDir::new("which_tests").unwrap(); + let tempdir = tempfile::tempdir().unwrap(); let mut builder = fs::DirBuilder::new(); builder.recursive(true); let mut paths = vec![]; @@ -63,25 +62,25 @@ impl TestFixture { for d in SUBDIRS.iter() { let p = tempdir.path().join(d); builder.create(&p).unwrap(); - bins.push(mk_bin(&p, &BIN_NAME, "").unwrap()); - bins.push(mk_bin(&p, &BIN_NAME, "exe").unwrap()); - bins.push(mk_bin(&p, &BIN_NAME, "cmd").unwrap()); + bins.push(mk_bin(&p, BIN_NAME, "").unwrap()); + bins.push(mk_bin(&p, BIN_NAME, "exe").unwrap()); + bins.push(mk_bin(&p, BIN_NAME, "cmd").unwrap()); paths.push(p); } TestFixture { - tempdir: tempdir, + tempdir, paths: env::join_paths(paths).unwrap(), - bins: bins, + bins, } } #[allow(dead_code)] pub fn touch(&self, path: &str, extension: &str) -> io::Result<PathBuf> { - touch(self.tempdir.path(), &path, &extension) + touch(self.tempdir.path(), path, extension) } pub fn mk_bin(&self, path: &str, extension: &str) -> io::Result<PathBuf> { - mk_bin(self.tempdir.path(), &path, &extension) + mk_bin(self.tempdir.path(), path, extension) } } @@ -89,11 +88,11 @@ 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, +fn _which_all<'a, T: AsRef<OsStr> + 'a>( + f: &'a 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()) +) -> which::Result<impl Iterator<Item = which::Result<which::CanonicalPath>> + '_> { + which::CanonicalPath::all_in(path, Some(f.paths.clone()), f.tempdir.path()) } #[test] @@ -165,10 +164,18 @@ fn test_which_re_in_without_matches() { #[test] #[cfg(all(unix, feature = "regex"))] fn test_which_re_accepts_owned_and_borrow() { - which::which_re(Regex::new(r".").unwrap()); - which::which_re(&Regex::new(r".").unwrap()); - which::which_re_in(Regex::new(r".").unwrap(), Some("pth")); - which::which_re_in(&Regex::new(r".").unwrap(), Some("pth")); + which::which_re(Regex::new(r".").unwrap()) + .unwrap() + .for_each(drop); + which::which_re(&Regex::new(r".").unwrap()) + .unwrap() + .for_each(drop); + which::which_re_in(Regex::new(r".").unwrap(), Some("pth")) + .unwrap() + .for_each(drop); + which::which_re_in(&Regex::new(r".").unwrap(), Some("pth")) + .unwrap() + .for_each(drop); } #[test] |