Re: [PATCH v3 3/4] t7005: sanitize test environment for subsequent tests
- From
D. Ben Knoble <ben.knoble+github@gmail.com>
- Date
- Aug 12, 2025, 16:40 UTC
- Message-ID
- <CALnO6CDaHZuC0=_Saccj3DuW-vaWs30PmwXf9dw1+AfsC34wWg@mail.gmail.com>
- In-Reply-To
- <CAPig+cThhm8b2vE=vAHYc5cEA9n232Lwi1c+p=LV9hK4hz=0Hw@mail.gmail.com>
On Mon, Aug 11, 2025 at 6:34 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 36 quoted lines
> > On Mon, Aug 11, 2025 at 6:17 PM D. Ben Knoble > <ben.knoble+github@gmail.com> wrote: > > 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 --amend > > References: > 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
Yep ;) I had the latter, switched (see range-diff, I think), and then CI caught me. Why doesn't the local test run catch it, though?