]> Cypherpunks repositories - gostls13.git/commit
cmd/go: report all loading errors in tests as "setup failed"
authorAustin Clements <austin@google.com>
Fri, 26 Jan 2024 19:45:30 +0000 (14:45 -0500)
committerAustin Clements <austin@google.com>
Sun, 17 Nov 2024 14:32:01 +0000 (14:32 +0000)
commit49b3ab0d81824f060b9ba459a076f6ff9ad04bc6
tree994f212b918c0ea66b62be3e214b22da1ad60e77
parent7020759859a3b7c2f033e497eca750b15d3aa38d
cmd/go: report all loading errors in tests as "setup failed"

Currently, under *most* circumstances, if there's a package loading
error during "go test", that will get reported as a "FAIL p [setup
failed]" or "FAIL p [build failed] message and won't prevent running
unaffected test packages.

However, if there's a loading error from a non-test file in a package
listed directly on the "go test" command line, that gets reported as
an immediate fatal error, without any "FAIL" line, and without
attempting to run other tests listed on the command line. Likewise,
certain early build errors (like a package containing no Go files) are
currently immediately fatal rather than reporting a test failure.

Fix this by eliminating the check that causes that immediate failure.
This causes one minor follow-up problem: since
load.TestPackagesAndErrors was never passed a top-level package with
an error before, it doesn't currently propagate such an error to the
packages it synthesizes (even though it will propagate errors in
imported packages). Fix this by copying the error from the top-level
package into the synthesized test package while we're copying
everything else.

For #62067.

Change-Id: Icd563a3d9912256b53afd998050995e5260ebe5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/558637
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
src/cmd/go/internal/load/test.go
src/cmd/go/internal/test/test.go
src/cmd/go/testdata/script/test_flags.txt
src/cmd/go/testdata/script/test_setup_error.txt [new file with mode: 0644]