From 9b0361e549949a208aa6bbcdff25506a3f97d7a9 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Tue, 25 Jul 2023 13:58:37 -0400 Subject: [PATCH] net: make mustHaveExternalNetwork work as usual on GOOS=linux I considered deleting mustHaveExternalNetwork in favor of just using the real testenv.MustHaveExternalNetwork. That certainly makes these tests that call it easier to understand. But that negatively affects some ports that don't have a longtest builder as it'd make the tests not run automatically on any builder at all. So, make a minimal change that applies only to GOOS=linux for now. If we make more progress on establishing -longtest builders for all ports, this intermediate layer helper will cease to have any benefit and can be deleted in favor of the one in testenv package. Change-Id: Iaea207d98e780db429ab49e6e227650a8b35b786 Reviewed-on: https://go-review.googlesource.com/c/go/+/513416 Run-TryBot: Dmitri Shuralyov Reviewed-by: Heschi Kreinick TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov --- src/net/dial_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/net/dial_test.go b/src/net/dial_test.go index ca9f0da3d3..784fb1d899 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -1052,13 +1052,20 @@ func TestDialerControlContext(t *testing.T) { } // mustHaveExternalNetwork is like testenv.MustHaveExternalNetwork -// except that it won't skip testing on non-mobile builders. +// except on non-Linux, non-mobile builders it permits the test to +// run in -short mode. func mustHaveExternalNetwork(t *testing.T) { t.Helper() + definitelyHasLongtestBuilder := runtime.GOOS == "linux" mobile := runtime.GOOS == "android" || runtime.GOOS == "ios" - if testenv.Builder() == "" || mobile { - testenv.MustHaveExternalNetwork(t) + if testenv.Builder() != "" && !definitelyHasLongtestBuilder && !mobile { + // On a non-Linux, non-mobile builder (e.g., freebsd-amd64-13_0). + // + // Don't skip testing because otherwise the test may never run on + // any builder if this port doesn't also have a -longtest builder. + return } + testenv.MustHaveExternalNetwork(t) } type contextWithNonZeroDeadline struct { -- 2.50.0