cmd/go: add check for unknown godebug setting

A //go:debug line mentioning an unknown or retired setting
should be diagnosed as making the program invalid. Do that.
We agreed on this in the proposal but I forgot to implement it.

Change-Id: Ie69072a1682d4eeb6866c02adbbb426f608567c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/476280
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Russ Cox 2023-03-14 14:25:56 -04:00
parent 44e51e60ac
commit 14ab998f95
21 changed files with 208 additions and 164 deletions

View file

@ -11,13 +11,13 @@ import (
)
func TestGet(t *testing.T) {
foo := New("foo")
foo := New("#foo")
tests := []struct {
godebug string
setting *Setting
want string
}{
{"", New(""), ""},
{"", New("#"), ""},
{"", foo, ""},
{"foo=bar", foo, "bar"},
{"foo=bar,after=x", foo, "bar"},
@ -28,7 +28,7 @@ func TestGet(t *testing.T) {
{"foo=", foo, ""},
{"foo", foo, ""},
{",foo", foo, ""},
{"foo=bar,baz", New("loooooooong"), ""},
{"foo=bar,baz", New("#loooooooong"), ""},
}
for _, tt := range tests {
t.Setenv("GODEBUG", tt.godebug)