Skip to content

Commit

Permalink
godoc: fix tests on Go 1.9
Browse files Browse the repository at this point in the history
Updates golang/go#11811
Updates golang/go#26531

Change-Id: I9cc7daf551b76c3f06b9dd827c5733513c06895e
Reviewed-on: https://go-review.googlesource.com/125816
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Agniva De Sarker <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
bradfitz committed Jul 25, 2018
1 parent 14e5710 commit 65cc56d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion godoc/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package godoc

import "testing"
import (
"go/build"
"testing"
)

func TestParseVersionRow(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -73,6 +76,17 @@ func TestParseVersionRow(t *testing.T) {
}
}

// hasTag checks whether a given release tag is contained in the current version
// of the go binary.
func hasTag(t string) bool {
for _, v := range build.Default.ReleaseTags {
if t == v {
return true
}
}
return false
}

func TestAPIVersion(t *testing.T) {
av, err := parsePackageAPIInfo()
if err != nil {
Expand Down Expand Up @@ -108,6 +122,9 @@ func TestAPIVersion(t *testing.T) {
{"type", "archive/tar", "Header", "", ""},
{"method", "archive/tar", "Next", "*Reader", ""},
} {
if tc.want != "" && !hasTag("go"+tc.want) {
continue
}
if got := av.sinceVersionFunc(tc.kind, tc.receiver, tc.name, tc.pkg); got != tc.want {
t.Errorf(`sinceFunc("%s", "%s", "%s", "%s") = "%s"; want "%s"`, tc.kind, tc.receiver, tc.name, tc.pkg, got, tc.want)
}
Expand Down

0 comments on commit 65cc56d

Please sign in to comment.