mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
update tests
This commit is contained in:
parent
0863369ff2
commit
b2b34e4ca2
@ -549,7 +549,9 @@ pub struct Dependency {
|
||||
name: String,
|
||||
vers: String,
|
||||
kind: String,
|
||||
artifact: Option<(String, Option<String>)>,
|
||||
artifact: Option<String>,
|
||||
bindep_target: Option<String>,
|
||||
lib: bool,
|
||||
target: Option<String>,
|
||||
features: Vec<String>,
|
||||
registry: Option<String>,
|
||||
@ -1409,13 +1411,20 @@ impl Package {
|
||||
(true, Some("alternative")) => None,
|
||||
_ => panic!("registry_dep currently only supports `alternative`"),
|
||||
};
|
||||
let artifact = if let Some(artifact) = &dep.artifact {
|
||||
serde_json::json!([artifact])
|
||||
} else {
|
||||
serde_json::json!(null)
|
||||
};
|
||||
serde_json::json!({
|
||||
"name": dep.name,
|
||||
"req": dep.vers,
|
||||
"features": dep.features,
|
||||
"default_features": true,
|
||||
"target": dep.target,
|
||||
"artifact": dep.artifact,
|
||||
"artifact": artifact,
|
||||
"bindep_target": dep.bindep_target,
|
||||
"lib": dep.lib,
|
||||
"optional": dep.optional,
|
||||
"kind": dep.kind,
|
||||
"registry": registry_url,
|
||||
@ -1536,11 +1545,14 @@ impl Package {
|
||||
"#,
|
||||
target, kind, dep.name, dep.vers
|
||||
));
|
||||
if let Some((artifact, target)) = &dep.artifact {
|
||||
if let Some(artifact) = &dep.artifact {
|
||||
manifest.push_str(&format!("artifact = \"{}\"\n", artifact));
|
||||
if let Some(target) = &target {
|
||||
manifest.push_str(&format!("target = \"{}\"\n", target))
|
||||
}
|
||||
}
|
||||
if let Some(target) = &dep.bindep_target {
|
||||
manifest.push_str(&format!("target = \"{}\"\n", target));
|
||||
}
|
||||
if dep.lib {
|
||||
manifest.push_str("lib = true\n");
|
||||
}
|
||||
if let Some(registry) = &dep.registry {
|
||||
assert_eq!(registry, "alternative");
|
||||
@ -1617,6 +1629,8 @@ impl Dependency {
|
||||
vers: vers.to_string(),
|
||||
kind: "normal".to_string(),
|
||||
artifact: None,
|
||||
bindep_target: None,
|
||||
lib: false,
|
||||
target: None,
|
||||
features: Vec::new(),
|
||||
package: None,
|
||||
@ -1646,7 +1660,8 @@ impl Dependency {
|
||||
/// Change the artifact to be of the given kind, like "bin", or "staticlib",
|
||||
/// along with a specific target triple if provided.
|
||||
pub fn artifact(&mut self, kind: &str, target: Option<String>) -> &mut Self {
|
||||
self.artifact = Some((kind.to_string(), target));
|
||||
self.artifact = Some(kind.to_string());
|
||||
self.bindep_target = target;
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -1445,13 +1445,7 @@ foo v0.0.0 ([CWD])
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
// TODO: Fix this potentially by reverting 887562bfeb8c540594d7d08e6e9a4ab7eb255865 which adds artifact information to the registry
|
||||
// followed by 0ff93733626f7cbecaf9dce9ab62b4ced0be088e which picks it up.
|
||||
// For reference, see comments by ehuss https://github.com/rust-lang/cargo/pull/9992#discussion_r801086315 and
|
||||
// joshtriplett https://github.com/rust-lang/cargo/pull/9992#issuecomment-1033394197 .
|
||||
#[cargo_test]
|
||||
#[ignore = "broken, need artifact info in index"]
|
||||
fn targets_are_picked_up_from_non_workspace_artifact_deps() {
|
||||
if cross_compile::disabled() {
|
||||
return;
|
||||
@ -1926,15 +1920,23 @@ You may press ctrl-c [..]
|
||||
"badges": {},
|
||||
"categories": [],
|
||||
"deps": [{
|
||||
"artifact": ["bin"],
|
||||
"default_features": true,
|
||||
"features": [],
|
||||
"kind": "normal",
|
||||
"lib": true,
|
||||
"name": "bar",
|
||||
"optional": false,
|
||||
"target": null,
|
||||
"version_req": "^1.0"
|
||||
},
|
||||
{
|
||||
"artifact": [
|
||||
"bin:a",
|
||||
"cdylib",
|
||||
"staticlib"
|
||||
],
|
||||
"bindep_target": "target",
|
||||
"default_features": true,
|
||||
"features": [],
|
||||
"kind": "build",
|
||||
@ -2894,8 +2896,7 @@ fn check_transitive_artifact_dependency_with_different_target() {
|
||||
p.cargo("check -Z bindeps")
|
||||
.masquerade_as_nightly_cargo(&["bindeps"])
|
||||
.with_stderr_contains(
|
||||
"error: could not find specification for target `custom-target`.\n \
|
||||
Dependency `baz v0.0.0 [..]` requires to build for target `custom-target`.",
|
||||
"error: failed to run `rustc` to learn about target-specific information",
|
||||
)
|
||||
.with_status(101)
|
||||
.run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user