]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/api: add exception file
authorRob Pike <r@golang.org>
Thu, 4 Oct 2012 01:35:17 +0000 (11:35 +1000)
committerRob Pike <r@golang.org>
Thu, 4 Oct 2012 01:35:17 +0000 (11:35 +1000)
Fixes build.

R=golang-dev, adg, bradfitz, dsymonds, dave
CC=golang-dev
https://golang.org/cl/6586074

api/README
api/except.txt [new file with mode: 0644]
src/cmd/api/goapi.go
src/run.bash

index 6adc55454c5840fb38c130ce21994640e6ceb2b2..34b86efd99766a7b5b9209206a8f5f0198a096ac 100644 (file)
@@ -5,6 +5,9 @@ Each file is a list of of API features, one per line.
 go1.txt (and similarly named files) are frozen once a version has been
 shipped. Each file adds new lines but does not remove any.
 
+except.txt lists features that may disappear without breaking
+true compatibility. The only package there is text/template/parse.
+
 next.txt is the only file intended to be mutated. It's a list of
 features that may be added to the next version. It only affects
 warning output from the go api tool.
diff --git a/api/except.txt b/api/except.txt
new file mode 100644 (file)
index 0000000..e9fb24b
--- /dev/null
@@ -0,0 +1,2 @@
+pkg text/template/parse, type DotNode bool
+pkg text/template/parse, type Node interface { Copy, String, Type }
index 7463e20d6dc40f4e1e1d288c4b347ae99e6321ae..391cbe76fac6f3babeb6f7eb774dc8d85727e6d9 100644 (file)
@@ -38,11 +38,12 @@ import (
 var (
        // TODO(bradfitz): once Go 1.1 comes out, allow the -c flag to take a comma-separated
        // list of files, rather than just one.
-       checkFile = flag.String("c", "", "optional filename to check API against")
-       allowNew  = flag.Bool("allow_new", true, "allow API additions")
-       nextFile  = flag.String("next", "", "optional filename of tentative upcoming API features for the next release. This file can be lazily maintained. It only affects the delta warnings from the -c file printed on success.")
-       verbose   = flag.Bool("v", false, "verbose debugging")
-       forceCtx  = flag.String("contexts", "", "optional comma-separated list of <goos>-<goarch>[-cgo] to override default contexts.")
+       checkFile  = flag.String("c", "", "optional filename to check API against")
+       allowNew   = flag.Bool("allow_new", true, "allow API additions")
+       exceptFile = flag.String("except", "", "optional filename of packages that are allowed to change without triggering a failure in the tool")
+       nextFile   = flag.String("next", "", "optional filename of tentative upcoming API features for the next release. This file can be lazily maintained. It only affects the delta warnings from the -c file printed on success.")
+       verbose    = flag.Bool("v", false, "verbose debugging")
+       forceCtx   = flag.String("contexts", "", "optional comma-separated list of <goos>-<goarch>[-cgo] to override default contexts.")
 )
 
 // contexts are the default contexts which are scanned, unless
@@ -198,6 +199,13 @@ func main() {
                }
        }
 
+       var exception = make(map[string]bool) // exception => true
+       if *exceptFile != "" {
+               for _, feature := range fileFeatures(*exceptFile) {
+                       exception[feature] = true
+               }
+       }
+
        take := func(sl *[]string) string {
                s := (*sl)[0]
                *sl = (*sl)[1:]
@@ -207,8 +215,13 @@ func main() {
        for len(required) > 0 || len(features) > 0 {
                switch {
                case len(features) == 0 || required[0] < features[0]:
-                       fmt.Fprintf(bw, "-%s\n", take(&required))
-                       fail = true // broke compatibility
+                       feature := take(&required)
+                       if exception[feature] {
+                               fmt.Fprintf(bw, "~%s\n", feature)
+                       } else {
+                               fmt.Fprintf(bw, "-%s\n", feature)
+                               fail = true // broke compatibility
+                       }
                case len(required) == 0 || required[0] > features[0]:
                        newFeature := take(&features)
                        if optional[newFeature] {
index f379ff5a7097d8d93ebbd5aa2f722e05d075a767..1859555fb17219a008e2b3eff68340b0c552b848 100755 (executable)
@@ -112,7 +112,7 @@ time go run run.go
 
 echo
 echo '# Checking API compatibility.'
-go tool api -c $GOROOT/api/go1.txt -next $GOROOT/api/next.txt
+go tool api -c $GOROOT/api/go1.txt -next $GOROOT/api/next.txt -except $GOROOT/api/except.txt
 
 echo
 echo ALL TESTS PASSED