unix: modernize test helpers

Test helper functions mktmpfifo and chtmpdir were written
before t.Cleanup was available, which necessitated returning
of a cleanup function and the use of defer.

Let's use t.Cleanup (available since Go 1.14) and simplify the callers.

While at it,
 - use t.Helper (added in Go 1.9);
 - simplify some error messages (errors that come from os package
   usually doesn't need to be wrapped).

Change-Id: Id981ae1c85fa2642a76358a31fc18a9af2f78711
Reviewed-on: https://go-review.googlesource.com/c/sys/+/526695
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Kir Kolyshkin
2023-09-14 22:16:50 +00:00
committed by Gopher Robot
parent a26c6dedca
commit 8d9dcc467b
6 changed files with 33 additions and 32 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ func TestTime(t *testing.T) {
}
func TestUtime(t *testing.T) {
defer chtmpdir(t)()
chtmpdir(t)
touch(t, "file1")