From: qmuntal Date: Thu, 20 Feb 2025 17:31:42 +0000 (+0100) Subject: os: don't log the entire environment in tests X-Git-Tag: go1.25rc1~957 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=64d82cd72c222caa93b2f71c5970a00ec4e7929a;p=gostls13.git os: don't log the entire environment in tests TestEnvironConsistency logs the values of all the environment variables, which can be quite large on some environments. This change limits the output to just the variables that caused the test to fail. Change-Id: Ie796b57ac2cc845093c73298058b720df344fa28 Reviewed-on: https://go-review.googlesource.com/c/go/+/650581 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek --- diff --git a/src/os/env_test.go b/src/os/env_test.go index e3de64196a..2515881db8 100644 --- a/src/os/env_test.go +++ b/src/os/env_test.go @@ -189,17 +189,13 @@ func TestEnvironConsistency(t *testing.T) { k := kv[:i] v := kv[i+1:] v2, ok := LookupEnv(k) - if ok && v == v2 { - t.Logf("LookupEnv(%q) = %q, %t", k, v2, ok) - } else { + if !ok || v != v2 { t.Errorf("Environ contains %q, but LookupEnv(%q) = %q, %t", kv, k, v2, ok) } // Since k=v is already present in the environment, // setting it should be a no-op. - if err := Setenv(k, v); err == nil { - t.Logf("Setenv(%q, %q)", k, v) - } else { + if err := Setenv(k, v); err != nil { t.Errorf("Environ contains %q, but SetEnv(%q, %q) = %q", kv, k, v, err) } }