mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
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:
committed by
Gopher Robot
parent
a26c6dedca
commit
8d9dcc467b
@@ -277,9 +277,8 @@ func TestPpoll(t *testing.T) {
|
||||
t.Skip("mkfifo syscall is not available on android, skipping test")
|
||||
}
|
||||
|
||||
defer chtmpdir(t)()
|
||||
f, cleanup := mktmpfifo(t)
|
||||
defer cleanup()
|
||||
chtmpdir(t)
|
||||
f := mktmpfifo(t)
|
||||
|
||||
const timeout = 100 * time.Millisecond
|
||||
|
||||
@@ -335,7 +334,7 @@ func TestTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUtime(t *testing.T) {
|
||||
defer chtmpdir(t)()
|
||||
chtmpdir(t)
|
||||
|
||||
touch(t, "file1")
|
||||
|
||||
@@ -548,7 +547,7 @@ func TestStatx(t *testing.T) {
|
||||
t.Fatalf("Statx: %v", err)
|
||||
}
|
||||
|
||||
defer chtmpdir(t)()
|
||||
chtmpdir(t)
|
||||
touch(t, "file1")
|
||||
|
||||
var st unix.Stat_t
|
||||
@@ -636,7 +635,7 @@ func stringsFromByteSlice(buf []byte) []string {
|
||||
}
|
||||
|
||||
func TestFaccessat(t *testing.T) {
|
||||
defer chtmpdir(t)()
|
||||
chtmpdir(t)
|
||||
touch(t, "file1")
|
||||
|
||||
err := unix.Faccessat(unix.AT_FDCWD, "file1", unix.R_OK, 0)
|
||||
|
||||
Reference in New Issue
Block a user