diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/xshell | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/xshell')
-rw-r--r-- | vendor/xshell/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/xshell/CHANGELOG.md | 4 | ||||
-rw-r--r-- | vendor/xshell/Cargo.lock | 10 | ||||
-rw-r--r-- | vendor/xshell/Cargo.toml | 21 | ||||
-rw-r--r-- | vendor/xshell/examples/ci.rs | 51 | ||||
-rw-r--r-- | vendor/xshell/src/error.rs | 12 | ||||
-rw-r--r-- | vendor/xshell/src/lib.rs | 15 | ||||
-rw-r--r-- | vendor/xshell/tests/it/main.rs | 18 |
8 files changed, 78 insertions, 55 deletions
diff --git a/vendor/xshell/.cargo-checksum.json b/vendor/xshell/.cargo-checksum.json index bb849f85b..762da9a20 100644 --- a/vendor/xshell/.cargo-checksum.json +++ b/vendor/xshell/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"c6e15e05c13991d47bbbd21c1fad9005c14de8dfca06a10c860fa1c70f1e069b","Cargo.lock":"1ee8c4b1409e8fecca09396a23d5199a29b04e6f710d04f0d4b5264279a6cb3c","Cargo.toml":"a4617f00daab17b57f080dff8b331d3847433a4fa65b30945d109df0aad6680b","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"a480b1b8b943c633c64ce9c215f8ecea24e58c7242fe4605d37e7a3be810ab9f","examples/ci.rs":"d5fbfc199469c08f3d459164c05a85c1a0a8f1bef625b347533ad7a43c1e97fb","examples/clone_and_publish.rs":"94568ef665e65527417bb5d50b0404bc60d6a72942d70260c8f3ce1a99820077","src/error.rs":"9222d0b21a889c9fbac1d285c6d43573be9c94f0ea5c02b4bd692bdc02753b49","src/lib.rs":"8bc6f4eab9734a46a717718001a79825a50874da324bb405b29adb17c6e2f220","tests/compile_time.rs":"224f3476eff4070fbd62c1974e7e69996efd92263bc12f7ddbd59823d85484da","tests/data/xecho.rs":"7a82252daade541bc3843fffa617fc50bf2faf7eebc55e4442a0bc9bb59182fd","tests/it/compile_failures.rs":"c87a438583c9f4b4e45a7422df3ee7c6bd5e69150eba5468425c63aa70fa47d3","tests/it/env.rs":"e863965669378e603c36186e1c738914e3d2300cbe3b04288a9ed689edcf09fb","tests/it/main.rs":"1bb089455f92d6486bf80502ebbbd1f136248194b9c454949f21ed279ea58028","tests/it/tidy.rs":"f530cf51504d43716e849ac96fb64a3a6ef80bd3e56b6eb1bd7b5325dc2f2de9"},"package":"962c039b3a7b16cf4e9a4248397c6585c07547412e7d6a6e035389a802dcfe90"}
\ No newline at end of file +{"files":{"CHANGELOG.md":"aedd43ff69a51c5d3cf774b233e68dbd2acdd5fc1d70b2147a68f2fb7a2c05ad","Cargo.lock":"918ba61867d1edcc63a6cd9d938e5172698c9c365540ebb82f10d2828446ee7e","Cargo.toml":"e29bca6fb43c0eb435b0de213946723dc35625bad89a2019bf42a206b644d702","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"a480b1b8b943c633c64ce9c215f8ecea24e58c7242fe4605d37e7a3be810ab9f","examples/ci.rs":"c00f300ef9cb19b621de2da627a120ff8119ee179ef7e89016ce15b40ded8f56","examples/clone_and_publish.rs":"94568ef665e65527417bb5d50b0404bc60d6a72942d70260c8f3ce1a99820077","src/error.rs":"4eec780f060db5357411c8b64fd2f371f796273bd77b29d8e442014704018aaf","src/lib.rs":"3c5ba47dd32df8e475c5aa45b3871b77da053faa010dc1178f63b15072cfa328","tests/compile_time.rs":"224f3476eff4070fbd62c1974e7e69996efd92263bc12f7ddbd59823d85484da","tests/data/xecho.rs":"7a82252daade541bc3843fffa617fc50bf2faf7eebc55e4442a0bc9bb59182fd","tests/it/compile_failures.rs":"c87a438583c9f4b4e45a7422df3ee7c6bd5e69150eba5468425c63aa70fa47d3","tests/it/env.rs":"e863965669378e603c36186e1c738914e3d2300cbe3b04288a9ed689edcf09fb","tests/it/main.rs":"f70a78ba72be45cdb7aed251ec5e07ec1997983e327380f77d841374b117058a","tests/it/tidy.rs":"f530cf51504d43716e849ac96fb64a3a6ef80bd3e56b6eb1bd7b5325dc2f2de9"},"package":"ce2107fe03e558353b4c71ad7626d58ed82efaf56c54134228608893c77023ad"}
\ No newline at end of file diff --git a/vendor/xshell/CHANGELOG.md b/vendor/xshell/CHANGELOG.md index 997a28d3c..bb62b24c0 100644 --- a/vendor/xshell/CHANGELOG.md +++ b/vendor/xshell/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.2.5 + +- Improve error message when a working directory for `cmd!` does not exist. + ## 0.2.3 - Fix bug where `Cmd::run` would ignore specified stdin. diff --git a/vendor/xshell/Cargo.lock b/vendor/xshell/Cargo.lock index bcea12812..3333f1a99 100644 --- a/vendor/xshell/Cargo.lock +++ b/vendor/xshell/Cargo.lock @@ -4,13 +4,13 @@ version = 3 [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "xshell" -version = "0.2.3" +version = "0.2.5" dependencies = [ "anyhow", "xshell-macros", @@ -18,6 +18,6 @@ dependencies = [ [[package]] name = "xshell-macros" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbabb1cbd15a1d6d12d9ed6b35cc6777d4af87ab3ba155ea37215f20beab80c" +checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" diff --git a/vendor/xshell/Cargo.toml b/vendor/xshell/Cargo.toml index 781152f51..0f3d3e0d3 100644 --- a/vendor/xshell/Cargo.toml +++ b/vendor/xshell/Cargo.toml @@ -13,15 +13,26 @@ edition = "2021" rust-version = "1.59" name = "xshell" -version = "0.2.3" +version = "0.2.5" authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"] -exclude = [".github/", "bors.toml", "rustfmt.toml", "cbench", "mock_bin/"] +exclude = [ + ".github/", + "bors.toml", + "rustfmt.toml", + "cbench", + "mock_bin/", +] description = "Utilities for quick shell scripting in Rust" -categories = ["development-tools::build-utils", "filesystem"] +readme = "README.md" +categories = [ + "development-tools::build-utils", + "filesystem", +] license = "MIT OR Apache-2.0" repository = "https://github.com/matklad/xshell" -resolver = "2" + [dependencies.xshell-macros] -version = "=0.2.3" +version = "=0.2.5" + [dev-dependencies.anyhow] version = "1.0.56" diff --git a/vendor/xshell/examples/ci.rs b/vendor/xshell/examples/ci.rs index 799b28824..8166447ae 100644 --- a/vendor/xshell/examples/ci.rs +++ b/vendor/xshell/examples/ci.rs @@ -1,7 +1,7 @@ //! This CI script for `xshell`. //! //! It also serves as a real-world example, yay bootstrap! -use std::{env, process, thread, time::Duration, time::Instant}; +use std::{env, process, time::Instant}; use xshell::{cmd, Result, Shell}; @@ -22,8 +22,12 @@ fn try_main() -> Result<()> { } fn test(sh: &Shell) -> Result<()> { - // Can't delete oneself on Windows. - if !cfg!(windows) { + // A good setup for CI is to compile & run in two steps, to get separate feedback for compile + // time and run time. However, because we are using the crate itself to run CI, if we are + // running this, we've already compiled a bunch of stuff. Originally we tried to `rm -rf + // .target`, but we also observed weird SIGKILL: 9 errors on mac. Perhaps its our self-removal? + // Let's scope it only to linux (windows won't work, bc one can not remove oneself there). + if cfg!(linux) { sh.remove_path("./target")?; } @@ -41,21 +45,9 @@ fn test(sh: &Shell) -> Result<()> { fn publish(sh: &Shell) -> Result<()> { let _s = Section::new("PUBLISH"); - let manifest = sh.read_file("./Cargo.toml")?; - let version = manifest - .lines() - .find_map(|line| { - let words = line.split_ascii_whitespace().collect::<Vec<_>>(); - match words.as_slice() { - [n, "=", v, ..] if n.trim() == "version" => { - assert!(v.starts_with('"') && v.ends_with('"')); - return Some(&v[1..v.len() - 1]); - } - _ => None, - } - }) - .unwrap(); + let pkgid = cmd!(sh, "cargo pkgid").read()?; + let (_path, version) = pkgid.rsplit_once('#').unwrap(); let tag = format!("v{}", version); let tags = cmd!(sh, "git tag --list").read()?; @@ -64,28 +56,11 @@ fn publish(sh: &Shell) -> Result<()> { let current_branch = cmd!(sh, "git branch --show-current").read()?; if current_branch == "master" && !tag_exists { - cmd!(sh, "git tag v{version}").run()?; - + // Could also just use `CARGO_REGISTRY_TOKEN` environmental variable. let token = sh.var("CRATES_IO_TOKEN").unwrap_or("DUMMY_TOKEN".to_string()); - { - let _p = sh.push_dir("xshell-macros"); - cmd!(sh, "cargo publish --token {token}").run()?; - for _ in 0..100 { - thread::sleep(Duration::from_secs(3)); - let err_msg = - cmd!(sh, "cargo install xshell-macros --version {version} --bin non-existing") - .ignore_status() - .read_stderr()?; - - let not_found = err_msg.contains("could not find "); - let tried_installing = err_msg.contains("Installing"); - assert!(not_found ^ tried_installing); - if tried_installing { - break; - } - } - } - cmd!(sh, "cargo publish --token {token}").run()?; + cmd!(sh, "git tag v{version}").run()?; + cmd!(sh, "cargo publish --token {token} --package xshell-macros").run()?; + cmd!(sh, "cargo publish --token {token} --package xshell").run()?; cmd!(sh, "git push --tags").run()?; } Ok(()) diff --git a/vendor/xshell/src/error.rs b/vendor/xshell/src/error.rs index 3e0f5dc3f..c35dcf426 100644 --- a/vendor/xshell/src/error.rs +++ b/vendor/xshell/src/error.rs @@ -12,7 +12,7 @@ pub struct Error { /// Note: this is intentionally not public. enum ErrorKind { - CurrentDir { err: io::Error }, + CurrentDir { err: io::Error, path: Option<PathBuf> }, Var { err: env::VarError, var: OsString }, ReadFile { err: io::Error, path: PathBuf }, ReadDir { err: io::Error, path: PathBuf }, @@ -37,7 +37,11 @@ impl From<ErrorKind> for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &*self.kind { - ErrorKind::CurrentDir { err } => write!(f, "failed to get current directory: {err}"), + ErrorKind::CurrentDir { err, path } => { + let suffix = + path.as_ref().map_or(String::new(), |path| format!(" `{}`", path.display())); + write!(f, "failed to get current directory{suffix}: {err}") + } ErrorKind::Var { err, var } => { let var = var.to_string_lossy(); write!(f, "failed to get environment variable `{var}`: {err}") @@ -113,8 +117,8 @@ impl std::error::Error for Error {} /// `pub(crate)` constructors, visible only in this crate. impl Error { - pub(crate) fn new_current_dir(err: io::Error) -> Error { - ErrorKind::CurrentDir { err }.into() + pub(crate) fn new_current_dir(err: io::Error, path: Option<PathBuf>) -> Error { + ErrorKind::CurrentDir { err, path }.into() } pub(crate) fn new_var(err: env::VarError, var: OsString) -> Error { diff --git a/vendor/xshell/src/lib.rs b/vendor/xshell/src/lib.rs index 02d6276f1..71be0979f 100644 --- a/vendor/xshell/src/lib.rs +++ b/vendor/xshell/src/lib.rs @@ -391,7 +391,7 @@ impl Shell { /// /// Fails if [`std::env::current_dir`] returns an error. pub fn new() -> Result<Shell> { - let cwd = current_dir().map_err(Error::new_current_dir)?; + let cwd = current_dir().map_err(|err| Error::new_current_dir(err, None))?; let cwd = RefCell::new(cwd); let env = RefCell::new(HashMap::new()); Ok(Shell { cwd, env }) @@ -1013,7 +1013,18 @@ impl<'a> Cmd<'a> { None => Stdio::null(), }); - command.spawn().map_err(|err| Error::new_cmd_io(self, err))? + command.spawn().map_err(|err| { + // Try to determine whether the command failed because the current + // directory does not exist. Return an appropriate error in such a + // case. + if matches!(err.kind(), io::ErrorKind::NotFound) { + let cwd = self.shell.cwd.borrow(); + if let Err(err) = cwd.metadata() { + return Error::new_current_dir(err, Some(cwd.clone())); + } + } + Error::new_cmd_io(self, err) + })? }; let mut io_thread = None; diff --git a/vendor/xshell/tests/it/main.rs b/vendor/xshell/tests/it/main.rs index 6ac8fe074..5dc5a851a 100644 --- a/vendor/xshell/tests/it/main.rs +++ b/vendor/xshell/tests/it/main.rs @@ -460,3 +460,21 @@ fn string_escapes() { assert_eq!(cmd!(sh, "\"\"\"asdf\"\"\"").to_string(), r##""""asdf""""##); assert_eq!(cmd!(sh, "\\\\").to_string(), r#"\\"#); } + +#[test] +fn nonexistent_current_directory() { + let sh = setup(); + sh.change_dir("nonexistent"); + let err = cmd!(sh, "ls").run().unwrap_err(); + let message = err.to_string(); + if cfg!(unix) { + assert!(message.contains("nonexistent"), "{message}"); + assert!(message.starts_with("failed to get current directory")); + assert!(message.ends_with("No such file or directory (os error 2)")); + } else { + assert_eq!( + message, + "io error when running command `ls`: The directory name is invalid. (os error 267)" + ); + } +} |