Skip to content

Commit

Permalink
Initial failing test creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-starlab committed Sep 10, 2021
1 parent 2274489 commit 577e650
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ features = [
[dev-dependencies]
cargo-test-macro = { path = "crates/cargo-test-macro" }
cargo-test-support = { path = "crates/cargo-test-support" }
pathdiff = "0.2.0"
regex = "1"

[build-dependencies]
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
Expand Down
5 changes: 4 additions & 1 deletion crates/cargo-test-support/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ pub fn add_submodule<'a>(
default_repo_cfg(&subrepo);
t!(subrepo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*"));
let mut origin = t!(subrepo.find_remote("origin"));
t!(origin.fetch(&Vec::<String>::new(), None, None));
dbg!(path);
let fetch = origin.fetch(&Vec::<String>::new(), None, None);
dbg!(&fetch);
t!(fetch);
t!(subrepo.checkout_head(None));
t!(s.add_finalize());
s
Expand Down
57 changes: 57 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use std::thread;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project};
use cargo_test_support::{sleep_ms, t, Project};
use pathdiff::diff_paths;
use std::fs::File;
use regex::Regex;

fn disable_git_cli() -> bool {
// mingw git on Windows does not support Windows-style file URIs.
Expand Down Expand Up @@ -943,6 +946,60 @@ fn dep_with_submodule() {
.run();
}

#[cargo_test]
fn dep_with_relative_submodule() {


let foo = project();
let base = git::new("base/base", |project| {
project.file("Cargo.toml", &basic_lib_manifest("base"))
.file("src/lib.rs", "pub fn dep() {}")
});
let deployment = git::new("deployment", |project| project.file("src/lib.rs", "pub fn dep() {}"));

let base_repo = git2::Repository::open(&base.root()).unwrap();
let temp = base.root().join("../../deployment").canonicalize().unwrap();
let deployment_url = temp.to_str().unwrap();
git::add_submodule(&base_repo, "../../deployment", Path::new("deployment"));
git::commit(&base_repo);

let project = foo
.file(
"Cargo.toml",
&format!(
r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["[email protected]"]
[dependencies.base]
git = '{}'
"#,
base.url()
),
)
.file(
"src/lib.rs",
"pub fn foo() { }",
)
.build();

project
.cargo("build")
.with_stderr(
"\
[UPDATING] git repository [..]
[UPDATING] git submodule `file://[..]/dep2`
[COMPILING] dep1 [..]
[COMPILING] foo [..]
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n",
)
.run();
}

#[cargo_test]
fn dep_with_bad_submodule() {
let project = project();
Expand Down

0 comments on commit 577e650

Please sign in to comment.