mirror of
https://github.com/golang/go.git
synced 2025-11-08 12:41:02 +00:00
cmd/api: make the test more robust
Previously, the TestCompareAPI test would fail if runtime.Version() is "dev", or, more importantly, "go1.5"; because compareAPI depends on runtime.Version and -allow_new flag. Move that logic out make its test more robust. Change-Id: I8f40daa1838b8acd26adac8848762d95315053b0 Reviewed-on: https://go-review.googlesource.com/8622 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
63d72f6901
commit
a50b24c649
2 changed files with 5 additions and 4 deletions
|
|
@ -202,7 +202,8 @@ func main() {
|
|||
}
|
||||
optional := fileFeatures(*nextFile)
|
||||
exception := fileFeatures(*exceptFile)
|
||||
fail = !compareAPI(bw, features, required, optional, exception)
|
||||
fail = !compareAPI(bw, features, required, optional, exception,
|
||||
*allowNew && strings.Contains(runtime.Version(), "devel"))
|
||||
}
|
||||
|
||||
// export emits the exported package features.
|
||||
|
|
@ -238,7 +239,7 @@ func featureWithoutContext(f string) string {
|
|||
return spaceParensRx.ReplaceAllString(f, "")
|
||||
}
|
||||
|
||||
func compareAPI(w io.Writer, features, required, optional, exception []string) (ok bool) {
|
||||
func compareAPI(w io.Writer, features, required, optional, exception []string, allowAdd bool) (ok bool) {
|
||||
ok = true
|
||||
|
||||
optionalSet := set(optional)
|
||||
|
|
@ -280,7 +281,7 @@ func compareAPI(w io.Writer, features, required, optional, exception []string) (
|
|||
delete(optionalSet, newFeature)
|
||||
} else {
|
||||
fmt.Fprintf(w, "+%s\n", newFeature)
|
||||
if !*allowNew || !strings.Contains(runtime.Version(), "devel") {
|
||||
if !allowAdd {
|
||||
ok = false // we're in lock-down mode for next release
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue