all: remove ioutil usage from tests

This removes the remaining (and trivial) use of deprecated ioutil
package from test files.

Replacements are easy:

	ioutil.ReadAll -> io.ReadAll
	ioutil.ReadDir -> os.ReadDir
	ioutil.ReadFile -> os.ReadFile
	ioutil.WriteFile -> os.WriteFile

While at it, simplify some error reporting.

Change-Id: I60a242fd3c08d8fe571a18f16716439a9acdd59d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/526299
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Kir Kolyshkin
2023-09-12 16:41:27 +00:00
committed by Gopher Robot
parent fc717d344a
commit fdc7ef4071
12 changed files with 31 additions and 38 deletions
+2 -3
View File
@@ -9,7 +9,6 @@ package svc_test
import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"os/exec"
@@ -202,7 +201,7 @@ func TestIsWindowsServiceWhenParentExits(t *testing.T) {
if isSvc {
msg = "IsWindowsService returns true when not running in a service."
}
err = ioutil.WriteFile(dumpPath, []byte(msg), 0644)
err = os.WriteFile(dumpPath, []byte(msg), 0644)
if err != nil {
// We cannot report this error. But main test will notice
// that we did not create dump file.
@@ -232,7 +231,7 @@ func TestIsWindowsServiceWhenParentExits(t *testing.T) {
t.Fatal("timed out waiting for child output file to be created.")
}
}
childOutput, err := ioutil.ReadFile(childDumpPath)
childOutput, err := os.ReadFile(childDumpPath)
if err != nil {
t.Fatalf("reading child output failed: %v", err)
}