cmd/go: fix at least some instances of double compilation

When the packages the tested package depends on don't build,
we weren't getting out early. Added a simple check for a successful
build to an existing early out.

There may be other ways that double compilation arises, but
this fixes the one listed in the issue.
Fixes issue 5679

R=golang-dev, rsc
CC=golang-dev
https://codereview.appspot.com/13036043