mirror of
https://github.com/rust-lang/cargo
synced 2024-07-20 17:47:45 +00:00
reproduce error msg in test case
This commit is contained in:
parent
0ba36c1c61
commit
d804b03afb
58
tests/git.rs
58
tests/git.rs
|
@ -751,6 +751,64 @@ fn dep_with_submodule() {
|
|||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n").with_status(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dep_with_bad_submodule() {
|
||||
let project = project("foo");
|
||||
let git_project = git::new("dep1", |project| {
|
||||
project
|
||||
.file("Cargo.toml", r#"
|
||||
[package]
|
||||
name = "dep1"
|
||||
version = "0.5.0"
|
||||
authors = ["carlhuda@example.com"]
|
||||
"#)
|
||||
}).unwrap();
|
||||
let git_project2 = git::new("dep2", |project| {
|
||||
project.file("lib.rs", "pub fn dep() {}")
|
||||
}).unwrap();
|
||||
|
||||
let repo = git2::Repository::open(&git_project.root()).unwrap();
|
||||
let url = path2url(git_project2.root()).to_string();
|
||||
git::add_submodule(&repo, &url, Path::new("src"));
|
||||
git::commit(&repo);
|
||||
|
||||
// now amend the first commit on git_project2 to make submodule ref point to not-found
|
||||
// commit
|
||||
let repo = git2::Repository::open(&git_project2.root()).unwrap();
|
||||
let original_submodule_ref = repo.refname_to_id("refs/heads/master").unwrap();
|
||||
let commit = repo.find_commit(original_submodule_ref).unwrap();
|
||||
commit.amend(Some("refs/heads/master"), None, None, None, Some("something something"), None).unwrap();
|
||||
|
||||
let project = project
|
||||
.file("Cargo.toml", &format!(r#"
|
||||
[project]
|
||||
|
||||
name = "foo"
|
||||
version = "0.5.0"
|
||||
authors = ["wycats@example.com"]
|
||||
|
||||
[dependencies.dep1]
|
||||
|
||||
git = '{}'
|
||||
"#, git_project.url()))
|
||||
.file("src/lib.rs", "
|
||||
extern crate dep1;
|
||||
pub fn foo() { dep1::dep() }
|
||||
");
|
||||
|
||||
assert_that(project.cargo_process("build").arg("--verbose"),
|
||||
execs().with_stderr(format!("\
|
||||
[UPDATING] git repository [..]
|
||||
[ERROR] failed to load source for a dependency on `dep1`
|
||||
|
||||
Caused by:
|
||||
Failed to update submodules of [..]
|
||||
|
||||
Caused by:
|
||||
[9/-3] object not found - no match for id ({})
|
||||
", original_submodule_ref)).with_status(101));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_deps_only_update_one() {
|
||||
let project = project("foo");
|
||||
|
|
Loading…
Reference in a new issue