From 21bd6b2a307c4b03b7299f96db5476750a008433 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Wed, 17 Jun 2026 00:22:41 +0200 Subject: [PATCH] Use idiomatic httptest handler failures in labs installer tests t.FailNow() is documented as illegal outside the test goroutine: called from an httptest handler it only kills the handler via runtime.Goexit, so the client sees a dropped connection rather than a clear test failure. Replace the four handler-goroutine occurrences with t.Errorf plus http.Error, and collapse the remaining test-goroutine t.Logf/t.FailNow pair to t.Fatal. Co-authored-by: Isaac --- cmd/labs/project/installer_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/labs/project/installer_test.go b/cmd/labs/project/installer_test.go index 8cfbbf034b3..266d42dbeb8 100644 --- a/cmd/labs/project/installer_test.go +++ b/cmd/labs/project/installer_test.go @@ -193,8 +193,8 @@ func TestInstallerWorksForReleases(t *testing.T) { }) return } - t.Logf("Requested: %s", r.URL.Path) - t.FailNow() + t.Errorf("unexpected request: %s", r.URL.Path) + http.Error(w, "unexpected request", http.StatusInternalServerError) })) defer server.Close() @@ -262,8 +262,8 @@ func TestOfflineInstallerWorksForReleases(t *testing.T) { }) return } - t.Logf("Requested: %s", r.URL.Path) - t.FailNow() + t.Errorf("unexpected request: %s", r.URL.Path) + http.Error(w, "unexpected request", http.StatusInternalServerError) })) defer server.Close() @@ -362,8 +362,8 @@ func TestInstallerWorksForDevelopment(t *testing.T) { }) return } - t.Logf("Requested: %s", r.URL.Path) - t.FailNow() + t.Errorf("unexpected request: %s", r.URL.Path) + http.Error(w, "unexpected request", http.StatusInternalServerError) })) defer server.Close() @@ -453,8 +453,8 @@ func TestUpgraderWorksForReleases(t *testing.T) { }) return } - t.Logf("Requested: %s", r.URL.Path) - t.FailNow() + t.Errorf("unexpected request: %s", r.URL.Path) + http.Error(w, "unexpected request", http.StatusInternalServerError) })) defer server.Close() @@ -496,7 +496,6 @@ func TestUpgraderWorksForReleases(t *testing.T) { } } if !pi { - t.Logf(`Expected stub command 'python[\S]+ -m pip install --upgrade --upgrade-strategy eager .' not found`) - t.FailNow() + t.Fatal(`Expected stub command 'python[\S]+ -m pip install --upgrade --upgrade-strategy eager .' not found`) } }