Skip to content

Commit

Permalink
Allow test to pass if user has ~/.gitconfig on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Oct 10, 2017
1 parent 446ed6e commit 4981004
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ fn cargo_process(s: &str) -> ProcessBuilder {
p
}

fn create_empty_gitconfig() {
// This helps on Windows where libgit2 is very aggressive in attempting to
// find a git config file.
let gitconfig = paths::home().join(".gitconfig");
File::create(gitconfig).unwrap();
}


#[test]
fn simple_lib() {
assert_that(cargo_process("new").arg("--lib").arg("foo").arg("--vcs").arg("none")
Expand Down Expand Up @@ -189,6 +197,7 @@ fn finds_author_user() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
create_empty_gitconfig();
assert_that(cargo_process("new").arg("foo").env("USER", "foo")
.cwd(td.path()),
execs().with_status(0));
Expand All @@ -204,6 +213,7 @@ fn finds_author_user_escaped() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
create_empty_gitconfig();
assert_that(cargo_process("new").arg("foo").env("USER", "foo \"bar\"")
.cwd(td.path()),
execs().with_status(0));
Expand All @@ -219,6 +229,7 @@ fn finds_author_username() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
create_empty_gitconfig();
assert_that(cargo_process("new").arg("foo")
.env_remove("USER")
.env("USERNAME", "foo")
Expand Down Expand Up @@ -255,6 +266,7 @@ fn finds_author_email() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
create_empty_gitconfig();
assert_that(cargo_process("new").arg("foo")
.env("USER", "bar")
.env("EMAIL", "baz")
Expand Down Expand Up @@ -326,6 +338,7 @@ fn finds_git_author() {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy
let td = TempDir::new("cargo").unwrap();
create_empty_gitconfig();
assert_that(cargo_process("new").arg("foo")
.env_remove("USER")
.env("GIT_COMMITTER_NAME", "gitfoo")
Expand Down

0 comments on commit 4981004

Please sign in to comment.