github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/compiler/version_check_test.go (about) 1 package compiler 2 3 import ( 4 "runtime" 5 "strings" 6 "testing" 7 ) 8 9 func TestGoRelease(t *testing.T) { 10 t.Run("goroot", func(t *testing.T) { 11 got := GoRelease(runtime.GOROOT()) 12 want := runtime.Version() 13 if got != want { 14 t.Fatalf("Got: goRelease(%q) returned %q. Want %s.", runtime.GOROOT(), got, want) 15 } 16 }) 17 18 t.Run("fallback", func(t *testing.T) { 19 const goroot = "./invalid goroot" 20 got := GoRelease(goroot) 21 if got == "" { 22 t.Fatalf("Got: goRelease(%q) returned \"\". Want: a Go version.", goroot) 23 } 24 if !strings.HasSuffix(Version, "+"+got) { 25 t.Fatalf("Got: goRelease(%q) returned %q. Want: a fallback to GopherJS version suffix %q.", goroot, got, Version) 26 } 27 }) 28 }