blob: 0f6068d68874424692acf98e01ae706ea086073e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package main
import (
"os"
"os/exec"
"testing"
)
func TestGoFormatted(t *testing.T) {
s, err := run("gofmt", "-l", ".")
if s != "" {
t.Fatalf("the following files are not gofmt'ed:\n%s", s)
}
if err != nil {
t.Error(err)
}
}
func TestGoVet(t *testing.T) {
s, err := run("go", "vet", "./...")
if s != "" {
t.Fatalf("go vet fails with:\n%s", s)
}
if err != nil {
t.Error(err)
}
}
func run(cmd string, args ...string) (string, error) {
c := exec.Command(cmd, args...)
c.Env = os.Environ()
b, err := c.CombinedOutput()
return string(b), err
}
|