go/packages: call testenv.NeedsGoPackages for TestDirAndForTest

To be consistent with other tests, and fix the breakage on js/wasm,
skip TestDirAndForTest on incompatible platforms.

Fixes golang/go#70286

Change-Id: I6195005e39103bbff4b5bb9ff99a63247eb0e9c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Rob Findley 2024-11-14 17:08:09 +00:00 коммит произвёл Gopher Robot
Родитель 47a5f7d131
Коммит a8d0fa56db
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -3212,6 +3212,8 @@ func foo() int {
// TestDirAndForTest tests the new fields added as part of golang/go#38445.
func TestDirAndForTest(t *testing.T) {
testenv.NeedsGoPackages(t)
dir := writeTree(t, `
-- go.mod --
module example.com
@ -3232,15 +3234,13 @@ func Bar() int { return 2 }
package a_test
import (
"testing"
"example.com/a"
"example.com/b"
)
func TestFooBar(t *testing.T) {
func _() {
if got := a.Foo() + a.Bar() + b.Baz(); got != 6 {
t.Errorf("whoops!")
panic("whoops")
}
}