Commit f69132d7 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

build: catch API changes during build

Adds new file api/go1.txt, locking down the current API.
Any changes to the API will need to update that file.

run.bash (but not make.bash, or Windows) will check for
accidental API changes.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5820070
parent 883a96d9
This diff is collapsed.
...@@ -131,7 +131,7 @@ func main() { ...@@ -131,7 +131,7 @@ func main() {
if err != nil { if err != nil {
log.Fatalf("Error reading file %s: %v", *checkFile, err) log.Fatalf("Error reading file %s: %v", *checkFile, err)
} }
v1 := strings.Split(string(bs), "\n") v1 := strings.Split(strings.TrimSpace(string(bs)), "\n")
sort.Strings(v1) sort.Strings(v1)
v2 := features v2 := features
take := func(sl *[]string) string { take := func(sl *[]string) string {
...@@ -139,17 +139,24 @@ func main() { ...@@ -139,17 +139,24 @@ func main() {
*sl = (*sl)[1:] *sl = (*sl)[1:]
return s return s
} }
changes := false
for len(v1) > 0 || len(v2) > 0 { for len(v1) > 0 || len(v2) > 0 {
switch { switch {
case len(v2) == 0 || v1[0] < v2[0]: case len(v2) == 0 || v1[0] < v2[0]:
fmt.Fprintf(bw, "-%s\n", take(&v1)) fmt.Fprintf(bw, "-%s\n", take(&v1))
changes = true
case len(v1) == 0 || v1[0] > v2[0]: case len(v1) == 0 || v1[0] > v2[0]:
fmt.Fprintf(bw, "+%s\n", take(&v2)) fmt.Fprintf(bw, "+%s\n", take(&v2))
changes = true
default: default:
take(&v1) take(&v1)
take(&v2) take(&v2)
} }
} }
if changes {
bw.Flush()
os.Exit(1)
}
} else { } else {
for _, f := range features { for _, f := range features {
fmt.Fprintf(bw, "%s\n", f) fmt.Fprintf(bw, "%s\n", f)
...@@ -284,7 +291,9 @@ func (w *Walker) WalkPackage(name string) { ...@@ -284,7 +291,9 @@ func (w *Walker) WalkPackage(name string) {
} }
} }
log.Printf("package %s", name) if *verbose {
log.Printf("package %s", name)
}
pop := w.pushScope("pkg " + name) pop := w.pushScope("pkg " + name)
defer pop() defer pop()
......
...@@ -74,7 +74,7 @@ make clean ...@@ -74,7 +74,7 @@ make clean
echo echo
echo '#' ../misc/dashboard/builder ../misc/goplay echo '#' ../misc/dashboard/builder ../misc/goplay
go build ../misc/dashboard/builder ../misc/goplay || exit $? go build ../misc/dashboard/builder ../misc/goplay
[ "$GOARCH" == arm ] || [ "$GOARCH" == arm ] ||
(xcd ../test/bench/shootout (xcd ../test/bench/shootout
...@@ -83,11 +83,15 @@ go build ../misc/dashboard/builder ../misc/goplay || exit $? ...@@ -83,11 +83,15 @@ go build ../misc/dashboard/builder ../misc/goplay || exit $?
echo echo
echo '#' ../test/bench/go1 echo '#' ../test/bench/go1
go test ../test/bench/go1 || exit $? go test ../test/bench/go1
(xcd ../test (xcd ../test
time go run run.go time go run run.go
) || exit $? ) || exit $?
echo
echo '# Checking API compatibility.'
go tool api -c $GOROOT/api/go1.txt
echo echo
echo ALL TESTS PASSED echo ALL TESTS PASSED
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment