summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/crates/cargo-test-support
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /src/tools/cargo/crates/cargo-test-support
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/crates/cargo-test-support')
-rw-r--r--src/tools/cargo/crates/cargo-test-support/Cargo.toml41
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/install.rs6
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/lib.rs33
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/publish.rs4
-rw-r--r--src/tools/cargo/crates/cargo-test-support/src/registry.rs15
5 files changed, 69 insertions, 30 deletions
diff --git a/src/tools/cargo/crates/cargo-test-support/Cargo.toml b/src/tools/cargo/crates/cargo-test-support/Cargo.toml
index 91e6e4e34..305c809a8 100644
--- a/src/tools/cargo/crates/cargo-test-support/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-test-support/Cargo.toml
@@ -3,30 +3,31 @@ name = "cargo-test-support"
version = "0.1.0"
license = "MIT OR Apache-2.0"
edition = "2021"
+publish = false
[lib]
doctest = false
[dependencies]
-anyhow = "1.0.34"
-cargo-test-macro = { path = "../cargo-test-macro" }
-cargo-util = { path = "../cargo-util" }
-crates-io = { path = "../crates-io" }
-filetime = "0.2"
-flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
-git2 = "0.17.0"
-glob = "0.3"
-itertools = "0.10.0"
-lazy_static = "1.0"
-pasetors = { version = "0.6.4", features = ["v3", "paserk", "std", "serde"] }
-serde = { version = "1.0.123", features = ["derive"] }
-serde_json = "1.0"
-snapbox = { version = "0.4.0", features = ["diff", "path"] }
-tar = { version = "0.4.38", default-features = false }
-termcolor = "1.1.2"
-time = { version = "0.3", features = ["parsing", "formatting"]}
-toml = "0.7.0"
-url = "2.2.2"
+anyhow.workspace = true
+cargo-test-macro.workspace = true
+cargo-util.workspace = true
+crates-io.workspace = true
+filetime.workspace = true
+flate2.workspace = true
+git2.workspace = true
+glob.workspace = true
+itertools.workspace = true
+lazy_static.workspace = true
+pasetors.workspace = true
+serde = { workspace = true, features = ["derive"] }
+serde_json.workspace = true
+snapbox.workspace = true
+tar.workspace = true
+termcolor.workspace = true
+time.workspace = true
+toml.workspace = true
+url.workspace = true
[target.'cfg(windows)'.dependencies]
-windows-sys = { version = "0.45.0", features = ["Win32_Storage_FileSystem"] }
+windows-sys = { workspace = true, features = ["Win32_Storage_FileSystem"] }
diff --git a/src/tools/cargo/crates/cargo-test-support/src/install.rs b/src/tools/cargo/crates/cargo-test-support/src/install.rs
index 478b482d2..02842ef7b 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/install.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/install.rs
@@ -4,8 +4,12 @@ use std::path::{Path, PathBuf};
/// Used by `cargo install` tests to assert an executable binary
/// has been installed. Example usage:
+/// ```no_run
+/// use cargo_test_support::install::assert_has_installed_exe;
+/// use cargo_test_support::install::cargo_home;
///
-/// assert_has_installed_exe(cargo_home(), "foo");
+/// assert_has_installed_exe(cargo_home(), "foo");
+/// ```
#[track_caller]
pub fn assert_has_installed_exe<P: AsRef<Path>>(path: P, name: &'static str) {
assert!(check_has_installed_exe(path, name));
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 04d6ce9f8..d27aab44f 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/lib.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/lib.rs
@@ -59,8 +59,8 @@ pub fn panic_error(what: &str, err: impl Into<anyhow::Error>) -> ! {
fn pe(what: &str, err: anyhow::Error) -> ! {
let mut result = format!("{}\nerror: {}", what, err);
for cause in err.chain().skip(1) {
- drop(writeln!(result, "\nCaused by:"));
- drop(write!(result, "{}", cause));
+ let _ = writeln!(result, "\nCaused by:");
+ let _ = write!(result, "{}", cause);
}
panic!("\n{}", result);
}
@@ -517,6 +517,29 @@ pub fn cargo_exe() -> PathBuf {
snapbox::cmd::cargo_bin("cargo")
}
+/// A wrapper around `rustc` instead of calling `clippy`.
+pub fn wrapped_clippy_driver() -> PathBuf {
+ let clippy_driver = project()
+ .at(paths::global_root().join("clippy-driver"))
+ .file("Cargo.toml", &basic_manifest("clippy-driver", "0.0.1"))
+ .file(
+ "src/main.rs",
+ r#"
+ fn main() {
+ let mut args = std::env::args_os();
+ let _me = args.next().unwrap();
+ let rustc = args.next().unwrap();
+ let status = std::process::Command::new(rustc).args(args).status().unwrap();
+ std::process::exit(status.code().unwrap_or(1));
+ }
+ "#,
+ )
+ .build();
+ clippy_driver.cargo("build").run();
+
+ clippy_driver.bin("clippy-driver")
+}
+
/// This is the raw output from the process.
///
/// This is similar to `std::process::Output`, however the `status` is
@@ -677,13 +700,15 @@ impl Execs {
/// The substrings are matched as `contains`. Example:
///
/// ```no_run
- /// execs.with_stderr_line_without(
+ /// use cargo_test_support::execs;
+ ///
+ /// execs().with_stderr_line_without(
/// &[
/// "[RUNNING] `rustc --crate-name build_script_build",
/// "-C opt-level=3",
/// ],
/// &["-C debuginfo", "-C incremental"],
- /// )
+ /// );
/// ```
///
/// This will check that a build line includes `-C opt-level=3` but does
diff --git a/src/tools/cargo/crates/cargo-test-support/src/publish.rs b/src/tools/cargo/crates/cargo-test-support/src/publish.rs
index 64774bc43..dccc8356d 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/publish.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/publish.rs
@@ -165,6 +165,7 @@ pub(crate) fn create_index_line(
features: crate::registry::FeatureMap,
yanked: bool,
links: Option<String>,
+ rust_version: Option<&str>,
v: Option<u32>,
) -> String {
// This emulates what crates.io does to retain backwards compatibility.
@@ -185,6 +186,9 @@ pub(crate) fn create_index_line(
if let Some(v) = v {
json["v"] = serde_json::json!(v);
}
+ if let Some(rust_version) = rust_version {
+ json["rust_version"] = serde_json::json!(rust_version);
+ }
json.to_string()
}
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 5faf23540..0cf82cb70 100644
--- a/src/tools/cargo/crates/cargo-test-support/src/registry.rs
+++ b/src/tools/cargo/crates/cargo-test-support/src/registry.rs
@@ -450,7 +450,10 @@ impl RegistryBuilder {
/// `VendorPackage` which implements directory sources.
///
/// # Example
-/// ```
+/// ```no_run
+/// use cargo_test_support::registry::Package;
+/// use cargo_test_support::project;
+///
/// // Publish package "a" depending on "b".
/// Package::new("a", "1.0.0")
/// .dep("b", "1.0.0")
@@ -1144,6 +1147,7 @@ fn save_new_crate(
false,
new_crate.links,
None,
+ None,
);
write_to_index(registry_path, &new_crate.name, line, false);
@@ -1240,7 +1244,7 @@ impl Package {
}
/// Adds a normal dependency. Example:
- /// ```
+ /// ```toml
/// [dependencies]
/// foo = {version = "1.0"}
/// ```
@@ -1249,7 +1253,7 @@ impl Package {
}
/// Adds a dependency with the given feature. Example:
- /// ```
+ /// ```toml
/// [dependencies]
/// foo = {version = "1.0", "features": ["feat1", "feat2"]}
/// ```
@@ -1272,7 +1276,7 @@ impl Package {
}
/// Adds a dev-dependency. Example:
- /// ```
+ /// ```toml
/// [dev-dependencies]
/// foo = {version = "1.0"}
/// ```
@@ -1281,7 +1285,7 @@ impl Package {
}
/// Adds a build-dependency. Example:
- /// ```
+ /// ```toml
/// [build-dependencies]
/// foo = {version = "1.0"}
/// ```
@@ -1400,6 +1404,7 @@ impl Package {
self.features.clone(),
self.yanked,
self.links.clone(),
+ self.rust_version.as_deref(),
self.v,
);