all: update _test.go files for ioutil changes
Этот коммит содержится в:
родитель
1784bcd728
коммит
f9ba99344a
9 изменённых файлов: 18 добавлений и 22 удалений
|
@ -2,7 +2,6 @@ package builder
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
@ -90,7 +89,7 @@ func testClangAttributes(t *testing.T, options *compileopts.Options) {
|
|||
|
||||
// Create a very simple C input file.
|
||||
srcpath := filepath.Join(testDir, "test.c")
|
||||
err = ioutil.WriteFile(srcpath, []byte("int add(int a, int b) { return a + b; }"), 0o666)
|
||||
err = os.WriteFile(srcpath, []byte("int add(int a, int b) { return a + b; }"), 0o666)
|
||||
if err != nil {
|
||||
t.Fatalf("could not write target file %s: %s", srcpath, err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"go/parser"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -107,7 +107,7 @@ func TestCGo(t *testing.T) {
|
|||
|
||||
// Read the file with the expected output, to compare against.
|
||||
outfile := filepath.Join("testdata", name+".out.go")
|
||||
expectedBytes, err := ioutil.ReadFile(outfile)
|
||||
expectedBytes, err := os.ReadFile(outfile)
|
||||
if err != nil {
|
||||
t.Fatalf("could not read expected output: %v", err)
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func TestCGo(t *testing.T) {
|
|||
// It is not. Test failed.
|
||||
if *flagUpdate {
|
||||
// Update the file with the expected data.
|
||||
err := ioutil.WriteFile(outfile, []byte(actual), 0666)
|
||||
err := os.WriteFile(outfile, []byte(actual), 0666)
|
||||
if err != nil {
|
||||
t.Error("could not write updated output file:", err)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package compiler
|
|||
import (
|
||||
"flag"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -162,14 +162,14 @@ func TestCompiler(t *testing.T) {
|
|||
|
||||
// Update test if needed. Do not check the result.
|
||||
if *flagUpdate {
|
||||
err := ioutil.WriteFile(outPath, []byte(mod.String()), 0666)
|
||||
err := os.WriteFile(outPath, []byte(mod.String()), 0666)
|
||||
if err != nil {
|
||||
t.Error("failed to write updated output file:", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
expected, err := ioutil.ReadFile(outPath)
|
||||
expected, err := os.ReadFile(outPath)
|
||||
if err != nil {
|
||||
t.Fatal("failed to read golden file:", err)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package interp
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -87,7 +86,7 @@ func runTest(t *testing.T, pathPrefix string) {
|
|||
pm.Run(mod)
|
||||
|
||||
// Read the expected output IR.
|
||||
out, err := ioutil.ReadFile(pathPrefix + ".out.ll")
|
||||
out, err := os.ReadFile(pathPrefix + ".out.ll")
|
||||
if err != nil {
|
||||
t.Fatalf("could not read output file %s: %v", pathPrefix+".out.ll", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
|
@ -319,7 +318,7 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
|
|||
if path[len(path)-1] == '/' {
|
||||
txtpath = path + "out.txt"
|
||||
}
|
||||
expected, err := ioutil.ReadFile(txtpath)
|
||||
expected, err := os.ReadFile(txtpath)
|
||||
if err != nil {
|
||||
t.Fatal("could not read expected output file:", err)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ package os_test
|
|||
|
||||
import (
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
. "os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
@ -198,13 +198,13 @@ func TestRenameOverwriteDest(t *testing.T) {
|
|||
toData := []byte("to")
|
||||
fromData := []byte("from")
|
||||
|
||||
err := ioutil.WriteFile(to, toData, 0777)
|
||||
err := os.WriteFile(to, toData, 0777)
|
||||
defer Remove(to) // TODO: switch to t.Tempdir, remove this line
|
||||
if err != nil {
|
||||
t.Fatalf("write file %q failed: %v", to, err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(from, fromData, 0777)
|
||||
err = os.WriteFile(from, fromData, 0777)
|
||||
defer Remove(from) // TODO: switch to t.Tempdir, remove this line
|
||||
if err != nil {
|
||||
t.Fatalf("write file %q failed: %v", from, err)
|
||||
|
|
|
@ -6,7 +6,7 @@ package os_test
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
. "os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -129,7 +129,7 @@ func TestSeek(t *testing.T) {
|
|||
off, err := f.Seek(tt.in, tt.whence)
|
||||
if off != tt.out || err != nil {
|
||||
if e, ok := err.(*PathError); ok && e.Err == syscall.EINVAL && tt.out > 1<<32 && runtime.GOOS == "linux" {
|
||||
mounts, _ := ioutil.ReadFile("/proc/mounts")
|
||||
mounts, _ := os.ReadFile("/proc/mounts")
|
||||
if strings.Contains(string(mounts), "reiserfs") {
|
||||
// Reiserfs rejects the big seeks.
|
||||
t.Skipf("skipping test known to fail on reiserfs; https://golang.org/issue/91")
|
||||
|
|
|
@ -2,7 +2,7 @@ package transform_test
|
|||
|
||||
import (
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
|
@ -62,7 +62,7 @@ func TestAllocs2(t *testing.T) {
|
|||
}
|
||||
|
||||
// Load expected test output (the OUT: lines).
|
||||
testInput, err := ioutil.ReadFile("./testdata/allocs2.go")
|
||||
testInput, err := os.ReadFile("./testdata/allocs2.go")
|
||||
if err != nil {
|
||||
t.Fatal("could not read test input:", err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"flag"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -58,13 +57,13 @@ func testTransform(t *testing.T, pathPrefix string, transform func(mod llvm.Modu
|
|||
actual = actual[strings.Index(actual, "\ntarget datalayout = ")+1:]
|
||||
|
||||
if *update {
|
||||
err := ioutil.WriteFile(pathPrefix+".out.ll", []byte(actual), 0666)
|
||||
err := os.WriteFile(pathPrefix+".out.ll", []byte(actual), 0666)
|
||||
if err != nil {
|
||||
t.Error("failed to write out new output:", err)
|
||||
}
|
||||
} else {
|
||||
// Read the expected output IR.
|
||||
out, err := ioutil.ReadFile(pathPrefix + ".out.ll")
|
||||
out, err := os.ReadFile(pathPrefix + ".out.ll")
|
||||
if err != nil {
|
||||
t.Fatalf("could not read output file %s: %v", pathPrefix+".out.ll", err)
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче