Re: [PATCH v3 3/4] t7005: sanitize test environment for subsequent tests
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Aug 11, 2025, 22:34 UTC
- Message-ID
- <CAPig+cThhm8b2vE=vAHYc5cEA9n232Lwi1c+p=LV9hK4hz=0Hw@mail.gmail.com>
- In-Reply-To
- <20250811221706.67168-4-ben.knoble+github@gmail.com>
On Mon, Aug 11, 2025 at 6:17 PM D. Ben Knoble <ben.knoble+github@gmail.com> wrote:
Show 18 quoted lines
> Some of the editor tests manipulate the environment or config in ways > that affect future tests, but those modifications are visible to future > tests and create a footgun for them. > > Use test_config, subshells, single-command environment overrides, and > test helpers to automatically undo environment and config modifications > once finished. > > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh > @@ -34,61 +34,57 @@ > -TERM=dumb > -export TERM > test_expect_success 'dumb should error out when falling back on vi' ' > - test_must_fail git commit --amend > + TERM=dumb test_must_fail git commit --amend > '
Don't use one-shot environment variable assignments when calling shell functions. Instead, you can do this:
test_env TERM=dumb test_must_fail git commit --amend
or employ the standard assignment/export boilerplate:
TERM=dumb &&
export TERM &&
test_must_fail git commit --amendReferences: https://lore.kernel.org/git/20240727053509.34339-1-ericsunshine@charter.net/T/#u https://lore.kernel.org/git/20180713055205.32351-1-sunshine@sunshineco.com/T/#u