From 4079305704ca86e2bc953caffe066eb97f5825fa Mon Sep 17 00:00:00 2001 From: Lucas Kent Date: Sun, 28 Apr 2024 17:30:21 +1000 Subject: [PATCH] Add failing test: artifact_dep_target_specified --- tests/testsuite/artifact_dep.rs | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index e04fb1bddf9..fd36a8386e2 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -1497,6 +1497,55 @@ foo v0.0.0 ([CWD]) ) .run(); } + +#[cargo_test] +fn artifact_dep_target_specified() { + if cross_compile::disabled() { + return; + } + let target = cross_compile::alternate(); + + let p = project() + .file( + "Cargo.toml", + &r#" + [package] + name = "foo" + version = "0.0.0" + authors = [] + resolver = "2" + + [dependencies] + bindep = { path = "bindep", artifact = "bin", target = "$TARGET" } + "# + .replace("$TARGET", target), + ) + .file("src/lib.rs", "") + .file("bindep/Cargo.toml", &basic_manifest("bindep", "0.0.0")) + .file("bindep/src/main.rs", "fn main() {}") + .build(); + + p.cargo("check -Z bindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stderr_contains( + r#"[COMPILING] bindep v0.0.0 ([CWD]/bindep) +[CHECKING] foo v0.0.0 ([CWD]) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]"#, + ) + .with_status(0) + .run(); + + // TODO: This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future. + p.cargo("tree -Z bindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stdout("") + .with_stderr_contains( + r#"activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev"# + ) + .with_status(101) + .run(); +} + #[cargo_test] fn targets_are_picked_up_from_non_workspace_artifact_deps() { if cross_compile::disabled() {