summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/crates
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/tools/cargo/crates
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/crates')
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/containers.rs4
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/lib.rs6
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/paths.rs21
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/registry.rs2
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/tools.rs15
-rw-r--r--src/tools/cargo/crates/cargo-util/Cargo.toml2
-rw-r--r--src/tools/cargo/crates/cargo-util/src/paths.rs17
-rw-r--r--src/tools/cargo/crates/resolver-tests/Cargo.toml1
-rw-r--r--src/tools/cargo/crates/resolver-tests/src/lib.rs4
-rw-r--r--src/tools/cargo/crates/resolver-tests/tests/resolve.rs4
10 files changed, 47 insertions, 29 deletions
diff --git a/src/tools/cargo/crates/cargo-test-support/src/containers.rs b/src/tools/cargo/crates/cargo-test-support/src/containers.rs
index 17040d82a..22fd5fd85 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/containers.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/containers.rs
@@ -94,7 +94,9 @@ impl Container {
let image_base = self.build_context.file_name().unwrap();
let image_name = format!("cargo-test-{}", image_base.to_str().unwrap());
- let _lock = BUILD_LOCK.lock().unwrap();
+ let _lock = BUILD_LOCK
+ .lock()
+ .map_err(|_| panic!("previous docker build failed, unable to run test"));
ProcessBuilder::new("docker")
.args(&["build", "--tag", image_name.as_str()])
.arg(&self.build_context)
diff --git a/src/tools/cargo/crates/cargo-test-support/src/lib.rs b/src/tools/cargo/crates/cargo-test-support/src/lib.rs
index d27aab44f..a2fa54c60 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/lib.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/lib.rs
@@ -110,7 +110,9 @@ impl FileBuilder {
fn mk(&mut self) {
if self.executable {
- self.path.set_extension(env::consts::EXE_EXTENSION);
+ let mut path = self.path.clone().into_os_string();
+ write!(path, "{}", env::consts::EXE_SUFFIX).unwrap();
+ self.path = path.into();
}
self.dirname().mkdir_p();
@@ -1259,6 +1261,8 @@ pub trait TestEnv: Sized {
.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "stable")
// Keeps cargo within its sandbox.
.env("__CARGO_TEST_DISABLE_GLOBAL_KNOWN_HOST", "1")
+ // Set retry sleep to 1 millisecond.
+ .env("__CARGO_TEST_FIXED_RETRY_SLEEP_MS", "1")
// Incremental generates a huge amount of data per test, which we
// don't particularly need. Tests that specifically need to check
// the incremental behavior should turn this back on.
diff --git a/src/tools/cargo/crates/cargo-test-support/src/paths.rs b/src/tools/cargo/crates/cargo-test-support/src/paths.rs
index ef1fddb70..50040e1d4 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/paths.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/paths.rs
@@ -1,7 +1,6 @@
use filetime::{self, FileTime};
-use lazy_static::lazy_static;
+
use std::cell::RefCell;
-use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::{self, ErrorKind};
@@ -9,15 +8,11 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
+use std::sync::OnceLock;
static CARGO_INTEGRATION_TEST_DIR: &str = "cit";
-lazy_static! {
- // TODO: Use `SyncOnceCell` when stable
- static ref GLOBAL_ROOT: Mutex<Option<PathBuf>> = Mutex::new(None);
-
- static ref TEST_ROOTS: Mutex<HashMap<String, PathBuf>> = Default::default();
-}
+static GLOBAL_ROOT: OnceLock<Mutex<Option<PathBuf>>> = OnceLock::new();
/// This is used when running cargo is pre-CARGO_TARGET_TMPDIR
/// TODO: Remove when CARGO_TARGET_TMPDIR grows old enough.
@@ -31,7 +26,10 @@ fn global_root_legacy() -> PathBuf {
}
fn set_global_root(tmp_dir: Option<&'static str>) {
- let mut lock = GLOBAL_ROOT.lock().unwrap();
+ let mut lock = GLOBAL_ROOT
+ .get_or_init(|| Default::default())
+ .lock()
+ .unwrap();
if lock.is_none() {
let mut root = match tmp_dir {
Some(tmp_dir) => PathBuf::from(tmp_dir),
@@ -44,7 +42,10 @@ fn set_global_root(tmp_dir: Option<&'static str>) {
}
pub fn global_root() -> PathBuf {
- let lock = GLOBAL_ROOT.lock().unwrap();
+ let lock = GLOBAL_ROOT
+ .get_or_init(|| Default::default())
+ .lock()
+ .unwrap();
match lock.as_ref() {
Some(p) => p.clone(),
None => unreachable!("GLOBAL_ROOT not set yet"),
diff --git a/src/tools/cargo/crates/cargo-test-support/src/registry.rs b/src/tools/cargo/crates/cargo-test-support/src/registry.rs
index 0cf82cb70..910f95bfa 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/registry.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/registry.rs
@@ -1342,7 +1342,7 @@ impl Package {
/// Sets the index schema version for this package.
///
- /// See `cargo::sources::registry::RegistryPackage` for more information.
+ /// See `cargo::sources::registry::IndexPackage` for more information.
pub fn schema_version(&mut self, version: u32) -> &mut Package {
self.v = Some(version);
self
diff --git a/src/tools/cargo/crates/cargo-test-support/src/tools.rs b/src/tools/cargo/crates/cargo-test-support/src/tools.rs
index 7c056b6fa..2ce2849ae 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/tools.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/tools.rs
@@ -1,20 +1,21 @@
//! Common executables that can be reused by various tests.
use crate::{basic_manifest, paths, project, Project};
-use lazy_static::lazy_static;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
+use std::sync::OnceLock;
-lazy_static! {
- static ref ECHO_WRAPPER: Mutex<Option<PathBuf>> = Mutex::new(None);
- static ref ECHO: Mutex<Option<PathBuf>> = Mutex::new(None);
-}
+static ECHO_WRAPPER: OnceLock<Mutex<Option<PathBuf>>> = OnceLock::new();
+static ECHO: OnceLock<Mutex<Option<PathBuf>>> = OnceLock::new();
/// Returns the path to an executable that works as a wrapper around rustc.
///
/// The wrapper will echo the command line it was called with to stderr.
pub fn echo_wrapper() -> PathBuf {
- let mut lock = ECHO_WRAPPER.lock().unwrap();
+ let mut lock = ECHO_WRAPPER
+ .get_or_init(|| Default::default())
+ .lock()
+ .unwrap();
if let Some(path) = &*lock {
return path.clone();
}
@@ -53,7 +54,7 @@ pub fn echo_wrapper() -> PathBuf {
///
/// Do not expect this to be anything fancy.
pub fn echo() -> PathBuf {
- let mut lock = ECHO.lock().unwrap();
+ let mut lock = ECHO.get_or_init(|| Default::default()).lock().unwrap();
if let Some(path) = &*lock {
return path.clone();
}
diff --git a/src/tools/cargo/crates/cargo-util/Cargo.toml b/src/tools/cargo/crates/cargo-util/Cargo.toml
index f01705fca..614581037 100644
--- a/src/tools/cargo/crates/cargo-util/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-util/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cargo-util"
-version = "0.2.4"
+version = "0.2.5"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/cargo-util/src/paths.rs b/src/tools/cargo/crates/cargo-util/src/paths.rs
index 69df7a209..4a917821b 100644
--- a/src/tools/cargo/crates/cargo-util/src/paths.rs
+++ b/src/tools/cargo/crates/cargo-util/src/paths.rs
@@ -55,6 +55,8 @@ pub fn dylib_path_envvar() -> &'static str {
// penalty starting in 10.13. Cargo's testsuite ran more than twice as
// slow with it on CI.
"DYLD_FALLBACK_LIBRARY_PATH"
+ } else if cfg!(target_os = "aix") {
+ "LIBPATH"
} else {
"LD_LIBRARY_PATH"
}
@@ -411,11 +413,22 @@ fn _create_dir_all(p: &Path) -> Result<()> {
Ok(())
}
-/// Recursively remove all files and directories at the given directory.
+/// Equivalent to [`std::fs::remove_dir_all`] with better error messages.
///
/// This does *not* follow symlinks.
pub fn remove_dir_all<P: AsRef<Path>>(p: P) -> Result<()> {
- _remove_dir_all(p.as_ref())
+ _remove_dir_all(p.as_ref()).or_else(|prev_err| {
+ // `std::fs::remove_dir_all` is highly specialized for different platforms
+ // and may be more reliable than a simple walk. We try the walk first in
+ // order to report more detailed errors.
+ fs::remove_dir_all(p.as_ref()).with_context(|| {
+ format!(
+ "{:?}\n\nError: failed to remove directory `{}`",
+ prev_err,
+ p.as_ref().display(),
+ )
+ })
+ })
}
fn _remove_dir_all(p: &Path) -> Result<()> {
diff --git a/src/tools/cargo/crates/resolver-tests/Cargo.toml b/src/tools/cargo/crates/resolver-tests/Cargo.toml
index 8a7cab113..e0efb9b6d 100644
--- a/src/tools/cargo/crates/resolver-tests/Cargo.toml
+++ b/src/tools/cargo/crates/resolver-tests/Cargo.toml
@@ -7,7 +7,6 @@ publish = false
[dependencies]
cargo.workspace = true
cargo-util.workspace = true
-is-terminal.workspace = true
lazy_static.workspace = true
proptest.workspace = true
varisat.workspace = true
diff --git a/src/tools/cargo/crates/resolver-tests/src/lib.rs b/src/tools/cargo/crates/resolver-tests/src/lib.rs
index 01d9b5e6d..ab34e8663 100644
--- a/src/tools/cargo/crates/resolver-tests/src/lib.rs
+++ b/src/tools/cargo/crates/resolver-tests/src/lib.rs
@@ -179,7 +179,6 @@ pub fn resolve_with_config_raw(
used: HashSet::new(),
};
let summary = Summary::new(
- config,
pkg_id("root"),
deps,
&BTreeMap::new(),
@@ -581,7 +580,6 @@ pub fn pkg_dep<T: ToPkgId>(name: T, dep: Vec<Dependency>) -> Summary {
None
};
Summary::new(
- &Config::default().unwrap(),
name.to_pkgid(),
dep,
&BTreeMap::new(),
@@ -610,7 +608,6 @@ pub fn pkg_loc(name: &str, loc: &str) -> Summary {
None
};
Summary::new(
- &Config::default().unwrap(),
pkg_id_loc(name, loc),
Vec::new(),
&BTreeMap::new(),
@@ -625,7 +622,6 @@ pub fn remove_dep(sum: &Summary, ind: usize) -> Summary {
deps.remove(ind);
// note: more things will need to be copied over in the future, but it works for now.
Summary::new(
- &Config::default().unwrap(),
sum.package_id(),
deps,
&BTreeMap::new(),
diff --git a/src/tools/cargo/crates/resolver-tests/tests/resolve.rs b/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
index df74826f0..02486bfb5 100644
--- a/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
+++ b/src/tools/cargo/crates/resolver-tests/tests/resolve.rs
@@ -1,3 +1,5 @@
+use std::io::IsTerminal;
+
use cargo::core::dependency::DepKind;
use cargo::core::Dependency;
use cargo::util::Config;
@@ -21,7 +23,7 @@ use proptest::prelude::*;
proptest! {
#![proptest_config(ProptestConfig {
max_shrink_iters:
- if is_ci() || !is_terminal::IsTerminal::is_terminal(&std::io::stderr()){
+ if is_ci() || !std::io::stderr().is_terminal() {
// This attempts to make sure that CI will fail fast,
0
} else {