Skip to content

Commit aa64447

Browse files
committed
test: add a case for running binary with same name as dependency
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 7bb7b53 commit aa64447

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/testsuite/run.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,3 +1566,47 @@ fn run_link_system_path_macos() {
15661566
p2.cargo("run").env(VAR, &libdir).run();
15671567
p2.cargo("test").env(VAR, &libdir).run();
15681568
}
1569+
1570+
#[cargo_test]
1571+
fn run_binary_with_same_name_as_dependency() {
1572+
let p = project()
1573+
.file(
1574+
"Cargo.toml",
1575+
r#"
1576+
[package]
1577+
name = "foo"
1578+
version = "0.5.0"
1579+
authors = []
1580+
1581+
[dependencies]
1582+
foo = { path = "foo" }
1583+
"#,
1584+
)
1585+
.file(
1586+
"src/main.rs",
1587+
r#"
1588+
fn main() {}
1589+
"#,
1590+
)
1591+
.file(
1592+
"foo/Cargo.toml",
1593+
r#"
1594+
[package]
1595+
name = "foo"
1596+
version = "0.1.0"
1597+
authors = []
1598+
1599+
[lib]
1600+
name = "foo"
1601+
path = "foo.rs"
1602+
"#,
1603+
)
1604+
.file("foo/foo.rs", "")
1605+
.build();
1606+
1607+
p.cargo("run").run();
1608+
p.cargo("run -p foo@0.5.0")
1609+
.with_status(101)
1610+
.with_stderr("[ERROR] package(s) `foo@0.5.0` not found in workspace [..]")
1611+
.run();
1612+
}

0 commit comments

Comments
 (0)