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>
diff --git a/go/analysis/unitchecker/unitchecker_test.go b/go/analysis/unitchecker/unitchecker_test.go
index 3b8d237..c6bb2bf 100644
--- a/go/analysis/unitchecker/unitchecker_test.go
+++ b/go/analysis/unitchecker/unitchecker_test.go
@@ -15,6 +15,7 @@
 	"os"
 	"os/exec"
 	"runtime"
+	"strings"
 	"testing"
 
 	"golang.org/x/tools/go/analysis/analysistest"
@@ -46,41 +47,46 @@
 // 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")
-	cmd.Env = append(os.Environ(),
-		"UNITCHECKER_CHILD=1",
-		"GOPATH="+testdata,
-	)
-
-	out, err := cmd.CombinedOutput()
-	exitcode := -1
-	if exitErr, ok := err.(*exec.ExitError); ok {
-		exitcode = exitErr.ExitCode()
-	}
-	if exitcode != 2 {
-		t.Errorf("got exit code %d, want 2", exitcode)
-	}
-
-	want := `
-# a
+	const wantA = `# a
 testdata/src/a/a.go:4:11: call of MyFunc123(...)
-# b
+`
+	const wantB = `# 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 t.Failed() {
-		t.Logf("err=%v stderr=<<%s>", err, cmd.Stderr)
+	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,
+		)
+
+		out, err := cmd.CombinedOutput()
+		exitcode := -1
+		if exitErr, ok := err.(*exec.ExitError); ok {
+			exitcode = exitErr.ExitCode()
+		}
+		if exitcode != 2 {
+			t.Errorf("%s: got exit code %d, want 2", test.args, exitcode)
+		}
+
+		if got := string(out); got != test.want {
+			t.Errorf("%s: got <<%s>>, want <<%s>>", test.args, got, test.want)
+		}
 	}
 }