Skip to content

Commit

Permalink
Ensure tests run on Go1.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
egonelbre committed Apr 3, 2019
1 parent 55ad5ec commit 6de8282
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
)

func TestRace(t *testing.T) {
tempfile, err := ioutil.TempFile("", "examplerace.*.go")
tempdir, err := ioutil.TempDir("", "race")
if err != nil {
t.Fatal(err)
}
filename := tempfile.Name()
t.Log(filename)
defer os.RemoveAll(tempdir)

defer os.Remove(filename)

_, err = tempfile.Write([]byte(`
filename := filepath.Join(tempdir, "example.go")
err = ioutil.WriteFile(filename, []byte(`
package main
import (
Expand Down Expand Up @@ -52,15 +51,11 @@ func TestRace(t *testing.T) {
wg.Wait()
}
`))
`), 0755)
if err != nil {
t.Fatal(err)
}

if err := tempfile.Close(); err != nil {
t.Fatal(err)
}

result, err := exec.Command("go", "run", "-race", filename).CombinedOutput()
if err != nil || len(result) != 0 {
t.Log(string(result))
Expand Down

0 comments on commit 6de8282

Please sign in to comment.