go/analysis/internal/unitchecker: reenable integration test
Fixes golang/go#28676 Change-Id: I361a5d61fb6acc90ff8c0167651a45cb9a433472 Reviewed-on: https://go-review.googlesource.com/c/149697 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
1a405fd27e
commit
5215be16cd
|
@ -15,6 +15,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/tools/go/analysis/analysistest"
|
||||
|
@ -46,15 +47,30 @@ func main() {
|
|||
// analysis with facts using unitchecker under "go vet".
|
||||
// It fork/execs the main function above.
|
||||
func TestIntegration(t *testing.T) {
|
||||
t.Skip("skipping broken test; golang.org/issue/28676")
|
||||
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skipf("skipping fork/exec test on this platform")
|
||||
}
|
||||
|
||||
testdata := analysistest.TestData()
|
||||
|
||||
cmd := exec.Command("go", "vet", "-vettool="+os.Args[0], "-findcall.name=MyFunc123", "b")
|
||||
const wantA = `# a
|
||||
testdata/src/a/a.go:4:11: call of MyFunc123(...)
|
||||
`
|
||||
const wantB = `# b
|
||||
testdata/src/b/b.go:6:13: call of MyFunc123(...)
|
||||
testdata/src/b/b.go:7:11: call of MyFunc123(...)
|
||||
`
|
||||
|
||||
for _, test := range []struct {
|
||||
args string
|
||||
want string
|
||||
}{
|
||||
{args: "a", want: wantA},
|
||||
{args: "b", want: wantB},
|
||||
{args: "a b", want: wantA + wantB},
|
||||
} {
|
||||
cmd := exec.Command("go", "vet", "-vettool="+os.Args[0], "-findcall.name=MyFunc123")
|
||||
cmd.Args = append(cmd.Args, strings.Fields(test.args)...)
|
||||
cmd.Env = append(os.Environ(),
|
||||
"UNITCHECKER_CHILD=1",
|
||||
"GOPATH="+testdata,
|
||||
|
@ -66,21 +82,11 @@ func TestIntegration(t *testing.T) {
|
|||
exitcode = exitErr.ExitCode()
|
||||
}
|
||||
if exitcode != 2 {
|
||||
t.Errorf("got exit code %d, want 2", exitcode)
|
||||
t.Errorf("%s: got exit code %d, want 2", test.args, exitcode)
|
||||
}
|
||||
|
||||
want := `
|
||||
# a
|
||||
testdata/src/a/a.go:4:11: call of MyFunc123(...)
|
||||
# b
|
||||
testdata/src/b/b.go:6:13: call of MyFunc123(...)
|
||||
testdata/src/b/b.go:7:11: call of MyFunc123(...)
|
||||
`[1:]
|
||||
if got := string(out); got != want {
|
||||
t.Errorf("got <<%s>>, want <<%s>>", got, want)
|
||||
if got := string(out); got != test.want {
|
||||
t.Errorf("%s: got <<%s>>, want <<%s>>", test.args, got, test.want)
|
||||
}
|
||||
|
||||
if t.Failed() {
|
||||
t.Logf("err=%v stderr=<<%s>", err, cmd.Stderr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue