Skip to content

Commit c847992

Browse files
committed
test: add test case to check replace-with error message
The test is used to duplicate #14697
1 parent 45ad483 commit c847992

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/testsuite/source_replacement.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,46 @@ fn source_replacement_with_registry_url() {
294294
"#]])
295295
.run();
296296
}
297+
298+
#[cargo_test]
299+
fn source_replacement_with_no_package_in_directoy() {
300+
let p = project()
301+
.file(
302+
"Cargo.toml",
303+
r#"
304+
[package]
305+
name = "foo"
306+
version = "0.1.0"
307+
edition = "2021"
308+
309+
[dependencies]
310+
bar = { version = "^0.8.9" }
311+
"#,
312+
)
313+
.file("src/lib.rs", "")
314+
.build();
315+
316+
let root = paths::root();
317+
t!(fs::create_dir(&root.join("vendor")));
318+
319+
let crates_io = setup_replacement(&format!(
320+
r#"
321+
[source.crates-io]
322+
replace-with = "vendored-sources"
323+
324+
[source.vendored-sources]
325+
directory = "vendor"
326+
"#
327+
));
328+
329+
p.cargo("build")
330+
.replace_crates_io(crates_io.index_url())
331+
.with_status(101)
332+
.with_stderr_data(str![[r#"
333+
[ERROR] no matching package named `bar` found
334+
location searched: registry `crates-io`
335+
required by package `foo v0.1.0 ([ROOT]/foo)`
336+
337+
"#]])
338+
.run();
339+
}

0 commit comments

Comments
 (0)