]> Cypherpunks repositories - gostls13.git/commit
testing: add Chdir
authorKir Kolyshkin <kolyshkin@gmail.com>
Fri, 8 Sep 2023 00:08:56 +0000 (17:08 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 16 Aug 2024 23:48:50 +0000 (23:48 +0000)
commit79ca434ac608d0817a5807d1c7b2138912ed55ce
tree763cfea963ab46503845d9333d8b5c18c65c539f
parentff271cd391bdb8963b5409c6f4cca40af8501b51
testing: add Chdir

Some tests need to use os.Chdir, but the use is complicated because
 - they must change back to the old working directory;
 - they must not use t.Parallel.

Add Chdir that covers these cases, and sets PWD environment variable
to the new directory for the duration of the test for Unix platforms.
Unify the panic message when t.Parallel is used together with t.Setenv
or t.Chdir.

Add some tests.

For #62516.

Change-Id: Ib050d173b26eb28a27dba5a206b2d0d877d761c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/529895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
api/next/62516.txt [new file with mode: 0644]
doc/next/6-stdlib/99-minor/testing/62516.md [new file with mode: 0644]
src/testing/export_test.go
src/testing/testing.go
src/testing/testing_test.go