[PATCH 1/2] t7005: sanitize test environment for subsequent tests
- From
D. Ben Knoble <ben.knoble+github@gmail.com>
- Date
- Aug 5, 2025, 02:40 UTC
- Message-ID
- <20250805024044.30024-2-ben.knoble+github@gmail.com>
- In-Reply-To
- <20250520193506.95199-1-ben.knoble+github@gmail.com>
Some of the editor tests manipulate the environment or config in ways that affect future tests (because they test a sequence of overrides), but those modifications are visible to future tests and create a footgun for them.
We can't make the environment-munging override tests undo their modifications because they rely on editor variables overriding other previously-set editor variables.
Use test_config and undo environment modifications once finished.
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- t/t7005-editor.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh index 5fcf281dfb..06fa1ecd91 100755 --- a/t/t7005-editor.sh +++ b/t/t7005-editor.sh @@ -111,6 +111,8 @@ ' done +unset EDITOR VISUAL GIT_EDITOR +git config --unset-all core.editor test_expect_success 'editor with a space' ' echo "echo space >\"\$1\"" >"e space.sh" && chmod a+x "e space.sh" && @@ -119,13 +121,10 @@ ' -unset GIT_EDITOR test_expect_success 'core.editor with a space' ' - - git config core.editor \"./e\ space.sh\" && + test_config core.editor \"./e\ space.sh\" && git commit --amend && test space = "$(git show -s --pretty=format:%s)" - ' test_done
-- 2.48.1