From: Eric Huss Date: Tue, 10 Oct 2017 00:52:51 +0000 (-0700) Subject: Allow test to pass if user has ~/.gitconfig on Windows. X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=4981004deb2956d8618b414f993844900438637f;p=cargo.git Allow test to pass if user has ~/.gitconfig on Windows. --- diff --git a/tests/new.rs b/tests/new.rs index 835ad1c02..91463273e 100644 --- a/tests/new.rs +++ b/tests/new.rs @@ -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") @@ -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)); @@ -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)); @@ -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") @@ -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") @@ -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")