From 2d8455372141a958429507dfb9740f47e3ad9d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Luka=C5=A1=C3=ADk?= Date: Mon, 21 Jul 2025 10:46:37 +0200 Subject: [PATCH] ci cleanup: make sure to remove test KUBECONFIGs Calling os.Exit() skipped the `defer os.RemoveAll(tmp)` above and thus dangling files & dirs would appear in their $TMPDIR. Since go1.15 we can safely remove os.Exit() from TestMain() function. As this exact issue was common enough so that go1.15 changed[1] the API of TestMain to no longer require os.Exit to be called. Reproducer: $ (cd staging/src/k8s.io/client-go; go test ./tools/clientcmd) $ ls -d /tmp/testkubeconfig* /tmp/testkubeconfig1015943687 [1]: https://go-review.googlesource.com/c/go/+/219639 Kubernetes-commit: 457df1cf9817e29381609fbf2d85854a6b6a52ac --- tools/clientcmd/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clientcmd/main_test.go b/tools/clientcmd/main_test.go index 0c56d19c..ba3b794d 100644 --- a/tools/clientcmd/main_test.go +++ b/tools/clientcmd/main_test.go @@ -29,5 +29,5 @@ func TestMain(m *testing.M) { } defer os.RemoveAll(tmp) os.Setenv("KUBECONFIG", filepath.Join(tmp, "dummy-nonexistent-kubeconfig")) - os.Exit(m.Run()) + m.Run() }