Skip to content

Commit 73c2ef9

Browse files
committed
update tests
1 parent 3439765 commit 73c2ef9

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,9 @@ pub struct Dependency {
549549
name: String,
550550
vers: String,
551551
kind: String,
552-
artifact: Option<(String, Option<String>)>,
552+
artifact: Option<String>,
553+
bindep_target: Option<String>,
554+
lib: bool,
553555
target: Option<String>,
554556
features: Vec<String>,
555557
registry: Option<String>,
@@ -1415,7 +1417,9 @@ impl Package {
14151417
"features": dep.features,
14161418
"default_features": true,
14171419
"target": dep.target,
1418-
"artifact": dep.artifact,
1420+
"artifact": [dep.artifact],
1421+
"bindep_target": dep.bindep_target,
1422+
"lib": dep.lib,
14191423
"optional": dep.optional,
14201424
"kind": dep.kind,
14211425
"registry": registry_url,
@@ -1536,11 +1540,14 @@ impl Package {
15361540
"#,
15371541
target, kind, dep.name, dep.vers
15381542
));
1539-
if let Some((artifact, target)) = &dep.artifact {
1543+
if let Some(artifact) = &dep.artifact {
15401544
manifest.push_str(&format!("artifact = \"{}\"\n", artifact));
1541-
if let Some(target) = &target {
1542-
manifest.push_str(&format!("target = \"{}\"\n", target))
1543-
}
1545+
}
1546+
if let Some(target) = &dep.bindep_target {
1547+
manifest.push_str(&format!("target = \"{}\"\n", target));
1548+
}
1549+
if dep.lib {
1550+
manifest.push_str("lib = true\n");
15441551
}
15451552
if let Some(registry) = &dep.registry {
15461553
assert_eq!(registry, "alternative");
@@ -1617,6 +1624,8 @@ impl Dependency {
16171624
vers: vers.to_string(),
16181625
kind: "normal".to_string(),
16191626
artifact: None,
1627+
bindep_target: None,
1628+
lib: false,
16201629
target: None,
16211630
features: Vec::new(),
16221631
package: None,
@@ -1646,7 +1655,8 @@ impl Dependency {
16461655
/// Change the artifact to be of the given kind, like "bin", or "staticlib",
16471656
/// along with a specific target triple if provided.
16481657
pub fn artifact(&mut self, kind: &str, target: Option<String>) -> &mut Self {
1649-
self.artifact = Some((kind.to_string(), target));
1658+
self.artifact = Some(kind.to_string());
1659+
self.bindep_target = target;
16501660
self
16511661
}
16521662

tests/testsuite/artifact_dep.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,13 +1445,7 @@ foo v0.0.0 ([CWD])
14451445
)
14461446
.run();
14471447
}
1448-
1449-
// TODO: Fix this potentially by reverting 887562bfeb8c540594d7d08e6e9a4ab7eb255865 which adds artifact information to the registry
1450-
// followed by 0ff93733626f7cbecaf9dce9ab62b4ced0be088e which picks it up.
1451-
// For reference, see comments by ehuss https://github.com/rust-lang/cargo/pull/9992#discussion_r801086315 and
1452-
// joshtriplett https://github.com/rust-lang/cargo/pull/9992#issuecomment-1033394197 .
14531448
#[cargo_test]
1454-
#[ignore = "broken, need artifact info in index"]
14551449
fn targets_are_picked_up_from_non_workspace_artifact_deps() {
14561450
if cross_compile::disabled() {
14571451
return;
@@ -1926,15 +1920,23 @@ You may press ctrl-c [..]
19261920
"badges": {},
19271921
"categories": [],
19281922
"deps": [{
1923+
"artifact": ["bin"],
19291924
"default_features": true,
19301925
"features": [],
19311926
"kind": "normal",
1927+
"lib": true,
19321928
"name": "bar",
19331929
"optional": false,
19341930
"target": null,
19351931
"version_req": "^1.0"
19361932
},
19371933
{
1934+
"artifact": [
1935+
"bin:a",
1936+
"cdylib",
1937+
"staticlib"
1938+
],
1939+
"bindep_target": "target",
19381940
"default_features": true,
19391941
"features": [],
19401942
"kind": "build",
@@ -2894,8 +2896,7 @@ fn check_transitive_artifact_dependency_with_different_target() {
28942896
p.cargo("check -Z bindeps")
28952897
.masquerade_as_nightly_cargo(&["bindeps"])
28962898
.with_stderr_contains(
2897-
"error: could not find specification for target `custom-target`.\n \
2898-
Dependency `baz v0.0.0 [..]` requires to build for target `custom-target`.",
2899+
"error: failed to run `rustc` to learn about target-specific information",
28992900
)
29002901
.with_status(101)
29012902
.run();

0 commit comments

Comments
 (0)