Skip to content

Commit

Permalink
test: revert changes in test directory
Browse files Browse the repository at this point in the history
  • Loading branch information
KimMachineGun committed Apr 3, 2021
1 parent 0522430 commit dda42b0
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 52 deletions.
3 changes: 2 additions & 1 deletion test/const7.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -62,7 +63,7 @@ func main() {
return
}

dir, err := os.MkdirTemp("", "const7_")
dir, err := ioutil.TempDir("", "const7_")
if err != nil {
log.Fatalf("creating temp dir: %v\n", err)
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/bug302.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -19,7 +20,7 @@ var tmpDir string
func main() {
fb, err := filepath.Abs("fixedbugs")
if err == nil {
tmpDir, err = os.MkdirTemp("", "bug302")
tmpDir, err = ioutil.TempDir("", "bug302")
}
if err != nil {
fmt.Println(err)
Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/bug369.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -20,7 +21,7 @@ func main() {
err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir"))
check(err)

tmpDir, err := os.MkdirTemp("", "bug369")
tmpDir, err := ioutil.TempDir("", "bug369")
check(err)
defer os.RemoveAll(tmpDir)

Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue11771.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -24,7 +25,7 @@ func main() {
return
}

dir, err := os.MkdirTemp("", "go-issue11771")
dir, err := ioutil.TempDir("", "go-issue11771")
if err != nil {
log.Fatalf("creating temp dir: %v\n", err)
}
Expand All @@ -47,7 +48,7 @@ func x() {
}
`)

if err := os.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil {
log.Fatal(err)
}

Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/issue13268.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package main

import (
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -22,7 +23,7 @@ import (

func main() {
// create source
f, err := os.CreateTemp("", "issue13268-")
f, err := ioutil.TempFile("", "issue13268-")
if err != nil {
log.Fatalf("could not create source file: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue16037_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"bytes"
"fmt"
"html/template"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -52,13 +53,13 @@ func main() {
log.Fatal(err)
}

dir, err := os.MkdirTemp("", "issue16037-")
dir, err := ioutil.TempDir("", "issue16037-")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(dir)
path := filepath.Join(dir, "ridiculous_number_of_fields.go")
if err := os.WriteFile(path, buf.Bytes(), 0664); err != nil {
if err := ioutil.WriteFile(path, buf.Bytes(), 0664); err != nil {
log.Fatal(err)
}

Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue19658.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -34,7 +35,7 @@ func main() {
`

func main() {
tempDir, err := os.MkdirTemp("", "")
tempDir, err := ioutil.TempDir("", "")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -69,7 +70,7 @@ func main() {
b := bytes.Buffer{}
fmt.Fprintf(&b, fn, tc.Type, tc.Input)

err = os.WriteFile(tmpFile, b.Bytes(), 0644)
err = ioutil.WriteFile(tmpFile, b.Bytes(), 0644)
if err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/issue21317.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
)

func main() {
f, err := os.CreateTemp("", "issue21317.go")
f, err := ioutil.TempFile("", "issue21317.go")
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue21576.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package main
import (
"bytes"
"context"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -33,14 +34,14 @@ func main() {
`

func main() {
dir, err := os.MkdirTemp("", "21576")
dir, err := ioutil.TempDir("", "21576")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(dir)

file := filepath.Join(dir, "main.go")
if err := os.WriteFile(file, []byte(prog), 0655); err != nil {
if err := ioutil.WriteFile(file, []byte(prog), 0655); err != nil {
log.Fatalf("Write error %v", err)
}

Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue22660.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -18,7 +19,7 @@ import (
)

func main() {
f, err := os.CreateTemp("", "issue22660.go")
f, err := ioutil.TempFile("", "issue22660.go")
if err != nil {
log.Fatal(err)
}
Expand All @@ -30,7 +31,7 @@ func main() {
var src bytes.Buffer
fmt.Fprintf(&src, "//line %s:1\n", filepath.Join(path, "foo.go"))

if err := os.WriteFile(f.Name(), src.Bytes(), 0660); err != nil {
if err := ioutil.WriteFile(f.Name(), src.Bytes(), 0660); err != nil {
log.Fatal(err)
}

Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue22662b.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package main

import (
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -35,15 +36,15 @@ var tests = []struct {
}

func main() {
f, err := os.CreateTemp("", "issue22662b.go")
f, err := ioutil.TempFile("", "issue22662b.go")
if err != nil {
log.Fatal(err)
}
f.Close()
defer os.Remove(f.Name())

for _, test := range tests {
if err := os.WriteFile(f.Name(), []byte(test.src), 0660); err != nil {
if err := ioutil.WriteFile(f.Name(), []byte(test.src), 0660); err != nil {
log.Fatal(err)
}

Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue26411.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -22,7 +23,7 @@ import (
)

func main() {
tmpdir, err := os.MkdirTemp("", "issue26411")
tmpdir, err := ioutil.TempDir("", "issue26411")
if err != nil {
log.Fatalf("Failed to create temporary directory: %v", err)
}
Expand Down Expand Up @@ -70,7 +71,7 @@ bar :

for i, test := range tests {
filename := filepath.Join(tmpdir, fmt.Sprintf("%d.go", i))
if err := os.WriteFile(filename, []byte(test.code), 0644); err != nil {
if err := ioutil.WriteFile(filename, []byte(test.code), 0644); err != nil {
log.Printf("#%d: failed to create file %s", i, filename)
continue
}
Expand Down
4 changes: 2 additions & 2 deletions test/fixedbugs/issue30908.dir/b.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package b

import (
"os"
"io/ioutil"

"./a"
)
Expand All @@ -27,7 +27,7 @@ func ReadValues(data []byte) (vals map[string]interface{}, err error) {
// of the output param.
func CallReadValues(filename string) (map[string]interface{}, error) {
defer func() { G++ }()
data, err := os.ReadFile(filename)
data, err := ioutil.ReadFile(filename)
if err != nil {
return map[string]interface{}{}, err
}
Expand Down
5 changes: 3 additions & 2 deletions test/fixedbugs/issue33555.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -55,14 +56,14 @@ func test() error {
}
fmt.Fprintf(&buf, fnlast, count)

dir, err := os.MkdirTemp("", "issue33555")
dir, err := ioutil.TempDir("", "issue33555")
if err != nil {
return err
}
defer os.RemoveAll(dir)

fn := filepath.Join(dir, "x.go")
if err := os.WriteFile(fn, buf.Bytes(), 0644); err != nil {
if err := ioutil.WriteFile(fn, buf.Bytes(), 0644); err != nil {
return err
}

Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/issue36437.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"regexp"
)

func main() {
tmpDir, err := os.MkdirTemp("", "issue36437")
tmpDir, err := ioutil.TempDir("", "issue36437")
if err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixedbugs/issue9355.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -19,7 +20,7 @@ func main() {
err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir"))
check(err)

f, err := os.CreateTemp("", "issue9355-*.o")
f, err := ioutil.TempFile("", "issue9355-*.o")
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
3 changes: 2 additions & 1 deletion test/linkmain_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -51,7 +52,7 @@ func runFail(cmdline ...string) {

func main() {
var err error
tmpDir, err = os.MkdirTemp("", "")
tmpDir, err = ioutil.TempDir("", "")
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
9 changes: 5 additions & 4 deletions test/linkobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand All @@ -20,7 +21,7 @@ import (
var pwd, tmpdir string

func main() {
dir, err := os.MkdirTemp("", "go-test-linkobj-")
dir, err := ioutil.TempDir("", "go-test-linkobj-")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -121,18 +122,18 @@ func runFail(args ...string) string {
}

func cp(src, dst string) {
data, err := os.ReadFile(src)
data, err := ioutil.ReadFile(src)
if err != nil {
fatalf("%v", err)
}
err = os.WriteFile(dst, data, 0666)
err = ioutil.WriteFile(dst, data, 0666)
if err != nil {
fatalf("%v", err)
}
}

func writeFile(name, data string) {
err := os.WriteFile(name, []byte(data), 0666)
err := ioutil.WriteFile(name, []byte(data), 0666)
if err != nil {
fatalf("%v", err)
}
Expand Down
Loading

0 comments on commit dda42b0

Please sign in to comment.