]> Cypherpunks repositories - gostls13.git/commit
cmd/go: make go list error behavior consistent in tests
authorJay Conrod <jayconrod@google.com>
Wed, 13 Feb 2019 23:35:19 +0000 (18:35 -0500)
committerJay Conrod <jayconrod@google.com>
Fri, 8 Mar 2019 20:22:16 +0000 (20:22 +0000)
commitf1d5ce0185fe184c016016d55f1718778b799f6d
treed2a8b9cdcdbc83b183301e4ad377c7ce3df1d4b5
parent1ab9f6837d6da80dad41657a913e47fa13a4fee8
cmd/go: make go list error behavior consistent in tests

"go list -test" constructs a package graph, then creates test packages
for the target. If it encounters an error (for example, a syntax error
in a test file or a test function with the wrong signature), it
reports the error and exits without printing the test packages or
their dependencies, even if the -e flag is given. This is a problem
for tools that operate on test files while users are editing them. For
example, autocomplete may not work while the user is typing.

With this change, a new function, load.TestPackagesAndErrors replaces
TestPackagesFor. The new function attaches errors to the returned test
packages instead of returning immediately. "go list -test" calls this
when the -e flag is set. TestPackagesFor now returns the same error as
before, but it returns non-nil packages so that "go list -test"
without -e can print partial results.

Fixes #28491

Change-Id: I141765c4574eae424d872eb9bf7dd63fdfb85efb
Reviewed-on: https://go-review.googlesource.com/c/go/+/164357
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/list/list.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/load/test.go
src/cmd/go/testdata/script/list_test_e.txt
src/cmd/go/testdata/script/list_test_err.txt [new file with mode: 0644]