aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid LeGare <legare@google.com>2022-04-22 09:24:06 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-22 09:24:06 +0000
commit8e29bf522994601897ea54df48eedf9cb455e787 (patch)
tree74b760abd18f993e3501cabf9342ccb8d6b484f5
parent8a13ffa045d80c5dee9335001e686c2d598bdc19 (diff)
parentdd6233041ca44c4d1dad2a0e46054a10fd0635f7 (diff)
downloadwhich-8e29bf522994601897ea54df48eedf9cb455e787.tar.gz
Upgrade rust/crates/which to 4.2.5 am: d9d261bae5 am: 7663b7b515 am: d4c1d30894 am: 3bdf596710 am: dd6233041c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/which/+/2066750 Change-Id: Ia05012c1e1ff6aa04bc710b167be590227ec0cf1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.github/workflows/rust.yml6
-rw-r--r--Android.bp2
-rw-r--r--Cargo.toml14
-rw-r--r--Cargo.toml.orig12
-rw-r--r--METADATA8
-rw-r--r--TEST_MAPPING6
-rw-r--r--src/checker.rs4
-rw-r--r--src/finder.rs5
-rw-r--r--tests/basic.rs49
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
diff --git a/Android.bp b/Android.bp
index 3d469f9..d41ae65 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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: [
diff --git a/Cargo.toml b/Cargo.toml
index 850a29c..3e5545f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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
diff --git a/METADATA b/METADATA
index 6a034c4..9d9dd01 100644
--- a/METADATA
+++ b/METADATA
@@ -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]