From c366795d8039d3f65f879385adab935d5f342272 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 23 Oct 2022 10:33:33 -0700 Subject: [PATCH] tests: remove obsolete workaround for `WorkingCopy` reading from `$HOME` Since d56ae79d3fc5, `WorkingCopy` no longer reads `.gitignores` directly from `$HOME/.gitignore`, so we don't need the workaround to prevent it in the tests. --- lib/src/testutils.rs | 8 -------- lib/tests/test_working_copy.rs | 7 ------- 2 files changed, 15 deletions(-) diff --git a/lib/src/testutils.rs b/lib/src/testutils.rs index 1e9f9401d..f62a3eaf9 100644 --- a/lib/src/testutils.rs +++ b/lib/src/testutils.rs @@ -42,14 +42,6 @@ pub fn new_temp_dir() -> TempDir { .unwrap() } -pub fn new_user_home() -> TempDir { - // Set $HOME to some arbitrary place so libgit2 doesn't use ~/.gitignore - // of the person running the tests. - let home_dir = new_temp_dir(); - std::env::set_var("HOME", home_dir.path()); - home_dir -} - pub fn user_settings() -> UserSettings { let config = config::Config::builder() .set_override("user.name", "Test User") diff --git a/lib/tests/test_working_copy.rs b/lib/tests/test_working_copy.rs index 599788665..e5a8d2c18 100644 --- a/lib/tests/test_working_copy.rs +++ b/lib/tests/test_working_copy.rs @@ -396,7 +396,6 @@ fn test_checkout_discard() { fn test_snapshot_racy_timestamps(use_git: bool) { // Tests that file modifications are detected even if they happen the same // millisecond as the updated working copy state. - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo; @@ -428,7 +427,6 @@ fn test_snapshot_racy_timestamps(use_git: bool) { fn test_snapshot_special_file() { // Tests that we ignore when special files (such as sockets and pipes) exist on // disk. - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, false); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -485,7 +483,6 @@ fn test_snapshot_special_file() { fn test_gitignores(use_git: bool) { // Tests that .gitignore files are respected. - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo; @@ -561,7 +558,6 @@ fn test_gitignores_checkout_never_overwrites_ignored(use_git: bool) { // Tests that a .gitignore'd file doesn't get overwritten if check out a commit // where the file is tracked. - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo; @@ -599,7 +595,6 @@ fn test_gitignores_ignored_directory_already_tracked(use_git: bool) { // Tests that a .gitignore'd directory that already has a tracked file in it // does not get removed when snapshotting the working directory. - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo; @@ -643,7 +638,6 @@ fn test_dotgit_ignored(use_git: bool) { // Tests that .git directories and files are always ignored (we could accept // them if the backend is not git). - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo; @@ -680,7 +674,6 @@ fn test_dotgit_ignored(use_git: bool) { #[test_case(false ; "local backend")] #[test_case(true ; "git backend")] fn test_existing_directory_symlink(use_git: bool) { - let _home_dir = testutils::new_user_home(); let settings = testutils::user_settings(); let mut test_workspace = TestWorkspace::init(&settings, use_git); let repo = &test_workspace.repo;