http2: add http2wrap test Add a test which reruns the package tests with -tags=http2wrap, when the Go version supports it. For #78508 Change-Id: I4ebf7e676de18f5d33e480e67997727d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/net/+/771221 Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/http2/wrap_test.go b/http2/wrap_test.go new file mode 100644 index 0000000..b8abb03 --- /dev/null +++ b/http2/wrap_test.go
@@ -0,0 +1,39 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.27 && !http2wrap + +package http2_test + +import ( + "os/exec" + "testing" +) + +func TestWrap(t *testing.T) { + goTest(t, "-tags=http2wrap", ".") +} + +// TestSuccess is a no-op test for confirming we can re-run "go test". +func TestSuccess(t *testing.T) {} + +func goTest(t *testing.T, args ...string) { + goTool, err := exec.LookPath("go") + if err != nil { + t.Skipf("can't find go tool: %v", err) + } + + // Skip this test if we can't run any tests at all. + checkCmd := exec.CommandContext(t.Context(), goTool, + "test", "-run=^TestSuccess$", ".") + if out, err := checkCmd.CombinedOutput(); err != nil { + t.Skipf("can't run trivial go test\n%s", out) + } + + testCmd := exec.CommandContext(t.Context(), goTool, "test") + testCmd.Args = append(testCmd.Args, args...) + if out, err := testCmd.CombinedOutput(); err != nil { + t.Fatalf("%q failed: %v\n%s", testCmd.Args, err, out) + } +}