Skip to content

Commit fc7b466

Browse files
committed
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>
1 parent 15c2cb1 commit fc7b466

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

http2/wrap_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2026 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build go1.27 && !http2wrap
6+
7+
package http2_test
8+
9+
import (
10+
"os/exec"
11+
"testing"
12+
)
13+
14+
func TestWrap(t *testing.T) {
15+
goTest(t, "-tags=http2wrap", ".")
16+
}
17+
18+
// TestSuccess is a no-op test for confirming we can re-run "go test".
19+
func TestSuccess(t *testing.T) {}
20+
21+
func goTest(t *testing.T, args ...string) {
22+
goTool, err := exec.LookPath("go")
23+
if err != nil {
24+
t.Skipf("can't find go tool: %v", err)
25+
}
26+
27+
// Skip this test if we can't run any tests at all.
28+
checkCmd := exec.CommandContext(t.Context(), goTool,
29+
"test", "-run=^TestSuccess$", ".")
30+
if out, err := checkCmd.CombinedOutput(); err != nil {
31+
t.Skipf("can't run trivial go test\n%s", out)
32+
}
33+
34+
testCmd := exec.CommandContext(t.Context(), goTool, "test")
35+
testCmd.Args = append(testCmd.Args, args...)
36+
if out, err := testCmd.CombinedOutput(); err != nil {
37+
t.Fatalf("%q failed: %v\n%s", testCmd.Args, err, out)
38+
}
39+
}

0 commit comments

Comments
 (0)