mirror of
https://github.com/golang/go
synced 2024-09-30 16:28:32 -06:00
go/packages: work around another case where go list doesn't respect -e
When there's an error running the C compiler for cgo, go list will produce output, but will also complain in stderr, and return a nonzero exit status. But it sholudn't return a non-zero exit status in that case when run with -e. Check for and suppress this case. Fixes golang/go#33462 Change-Id: Idae0970000a0cb134386f5e66d2b63b348ec8576 Reviewed-on: https://go-review.googlesource.com/c/tools/+/190339 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
f60b6e7d83
commit
9fae7b2cd5
@ -884,6 +884,12 @@ func invokeGo(cfg *Config, args ...string) (*bytes.Buffer, error) {
|
||||
return nil, fmt.Errorf("%s", stderr.String())
|
||||
}
|
||||
|
||||
// Is there an error running the C compiler in cgo? This will be reported in the "Error" field
|
||||
// and should be suppressed by go list -e.
|
||||
if len(stderr.String()) > 0 && strings.HasPrefix(stderr.String(), "# runtime/cgo\n") && strings.Count(stderr.String(), "\n") == 2 {
|
||||
return stdout, nil
|
||||
}
|
||||
|
||||
// This error only appears in stderr. See golang.org/cl/166398 for a fix in go list to show
|
||||
// the error in the Err section of stdout in case -e option is provided.
|
||||
// This fix is provided for backwards compatibility.
|
||||
|
@ -2107,9 +2107,6 @@ func testAdHocContains(t *testing.T, exporter packagestest.Exporter) {
|
||||
|
||||
func TestNoCcompiler(t *testing.T) { packagestest.TestAll(t, testNoCcompiler) }
|
||||
func testNoCcompiler(t *testing.T, exporter packagestest.Exporter) {
|
||||
// Enable this test after golang/go#33462 is resolved.
|
||||
t.Skip()
|
||||
|
||||
exported := packagestest.Export(t, exporter, []packagestest.Module{{
|
||||
Name: "golang.org/fake",
|
||||
Files: map[string]interface{}{
|
||||
|
Loading…
Reference in New Issue
Block a user