]> Cypherpunks repositories - gostls13.git/commitdiff
doc/progs: rewrite test driver in Go
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 2 Apr 2015 15:53:27 +0000 (08:53 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 7 Apr 2015 00:41:59 +0000 (00:41 +0000)
The tests in doc/progs appear to have been originally written
for use with the old test driver. At some later point,
they acquired their own test driver.
Both ran tests in serial.

This CL rewrites the current test driver in Go,
runs tests concurrently, and cleans up
historical artifacts from the old drivers.

The primary motivation is to speed up all.bash.
On my laptop, using tip, this CL reduces doc/progs test
wall time from 26s to 7s. The savings will remain
even when the compiler gets faster. Using Go 1.4,
this CL reduces test wall time from 15s to 4s.

Change-Id: Iae945a8490222beee76e8a2118a0d7956092f543
Reviewed-on: https://go-review.googlesource.com/8410
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

51 files changed:
doc/progs/cgo1.go
doc/progs/cgo2.go
doc/progs/cgo3.go
doc/progs/cgo4.go
doc/progs/defer.go
doc/progs/defer.out [deleted file]
doc/progs/defer2.go
doc/progs/defer2.out [deleted file]
doc/progs/eff_bytesize.go
doc/progs/eff_bytesize.out [deleted file]
doc/progs/eff_qr.go
doc/progs/eff_sequence.go
doc/progs/eff_sequence.out [deleted file]
doc/progs/eff_unused1.go
doc/progs/eff_unused2.go
doc/progs/error.go
doc/progs/error2.go
doc/progs/error3.go
doc/progs/error4.go
doc/progs/go1.go
doc/progs/gobs1.go
doc/progs/gobs2.go
doc/progs/image_draw.go
doc/progs/image_package1.go
doc/progs/image_package1.out [deleted file]
doc/progs/image_package2.go
doc/progs/image_package2.out [deleted file]
doc/progs/image_package3.go
doc/progs/image_package3.out [deleted file]
doc/progs/image_package4.go
doc/progs/image_package4.out [deleted file]
doc/progs/image_package5.go
doc/progs/image_package5.out [deleted file]
doc/progs/image_package6.go
doc/progs/image_package6.out [deleted file]
doc/progs/interface.go
doc/progs/interface2.go
doc/progs/interface2.out [deleted file]
doc/progs/json1.go
doc/progs/json2.go
doc/progs/json2.out [deleted file]
doc/progs/json3.go
doc/progs/json4.go
doc/progs/json5.go
doc/progs/run [deleted file]
doc/progs/run.go [new file with mode: 0755]
doc/progs/slices.go
doc/progs/timeout1.go
doc/progs/timeout2.go
doc/progs/update.bash [deleted file]
src/cmd/dist/test.go

index 805fe3c9c546cca76933b51134f99f444f3f564c..d559e13931933da1910e11ed2f352471e645a18b 100644 (file)
@@ -1,8 +1,7 @@
-// skip
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package rand
 
 /*
index b9e9f7d9709efac287bfff6261704cc583c7160a..da07aa49e6ed3c1ec76de962b27b0e261ef9e653 100644 (file)
@@ -1,8 +1,7 @@
-// skip
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package rand2
 
 /*
index c4f4791e8c7e8483746294f782ba32ccd6c443b6..d5cedf4960a51f38ac6d503631225ef5f43cf438 100644 (file)
@@ -1,8 +1,7 @@
-// skip
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package print
 
 // #include <stdio.h>
index 30b8935723c837bfe422991d8c035ab804c5c953..dbb07e84fe43cb4e8dbe03213acd114d64955963 100644 (file)
@@ -1,8 +1,7 @@
-// skip
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package print
 
 // #include <stdio.h>
index 006a474b5d0b2ee5dae1e14f06925f034ad97c91..2e11020abf54ce4506afc68e80ee70cdb8db7a91 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/defer.out b/doc/progs/defer.out
deleted file mode 100644 (file)
index 0cdf53a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-0
-3210
-2
index ff7eaf9d890cf4cf8e00a0255f13ea63f236eeda..cad66b0702b3d49c0f338ef0c627fa8940452508 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/defer2.out b/doc/progs/defer2.out
deleted file mode 100644 (file)
index 6110685..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Calling g.
-Printing in g 0
-Printing in g 1
-Printing in g 2
-Printing in g 3
-Panicking!
-Defer in g 3
-Defer in g 2
-Defer in g 1
-Defer in g 0
-Recovered in f 4
-Returned normally from f.
index a0c3d505850a6eaa33a690109b9ff099b9709cb1..b45961114dd3bd81d0d3e2f587bf3ad67561a8df 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/eff_bytesize.out b/doc/progs/eff_bytesize.out
deleted file mode 100644 (file)
index df763f3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-1.00YB 9.09TB
index 861131ddf54b5ea8b708d2ce241ec7bf0ebfe4e0..89de459f7da370af072b4d45679d2744b9e9c2db 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index c9b18ba93547740e39a017c97c8607ffb122a681..11c885abf82a34013248c5246167434f4f8776da 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/eff_sequence.out b/doc/progs/eff_sequence.out
deleted file mode 100644 (file)
index fd01a7d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-[-1 2 6 16 44]
index f990a19f77ab7f24957db59700f189479f5f110f..285d55eee53a5338ca0966edae2176f56e72146a 100644 (file)
@@ -1,5 +1,3 @@
-// skip
-
 package main
 
 import (
index 3e6e041c76e7515461ea263bb3ca9dbc34988ef8..92eb74e0534f3b54b56e56aeda75294bdf879a01 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 package main
 
 import (
index 57854c5fe5a805758df9ce8b9a7542642b40debe..e776cdba17738fe9974806e231f4a29922149c85 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index aad1dc8e8ef47697f6ef7a5dc4170b03224a2150..2b0e0c3563a56d4738ec6deadcb850e2490624a1 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index 9f1b3007279b98c4a258caf60dc8669333de39e7..e4e57e077b52ace4126868985272fe060e5d9b5d 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index d40fc6eb237f665782b5e9f3e568373222b72737..8b2f3049de272a1b0152f0c05b5c19f6fcc340e7 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index a4dc64d469668bee636233a6bd0108b24a009b9c..50fd93441f477e636e4a0274b09448717ceddff5 100644 (file)
@@ -1,6 +1,3 @@
-// compile
-// this file will output a list of filenames in cwd, not suitable for cmpout
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index d95f765d811cb13083946e3bfd38520780dbd904..7077ca159f994d78aadd3e516d804403f6dbd9fe 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index acd18382f71f4c3d7830097d386f5f85adeddf04..85bb41cdca72f1c357794dc7b46b16b6dbfba274 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index 0a1f7acb1a6c62990398e1fc87e42d2942e2c87e..bb73c8a714f0fc752d34a12445b91023bf27f0f7 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index d331834fc6b7e40a17ae85b843c348e9fed71393..c4c401e729e9eab6ea8e77ce7d1edb32d0758b6b 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package1.out b/doc/progs/image_package1.out
deleted file mode 100644 (file)
index 809b31b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-X is 2 Y is 1
index e5b78b48521edd6604c8d448c9afc62b72f6d05b..fcb5d9fd039298abb26458b868d95a1b056e8588 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package2.out b/doc/progs/image_package2.out
deleted file mode 100644 (file)
index 616d307..0000000
+++ /dev/null
@@ -1 +0,0 @@
-3 4 false
index 95d72a0b2e3fae19e134f34faf064d3be8c4e5e3..13d0f08079c7b361599a864607f9a86488e11547 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package3.out b/doc/progs/image_package3.out
deleted file mode 100644 (file)
index 3fe35de..0000000
+++ /dev/null
@@ -1 +0,0 @@
-3 4 true
index ec0e4613d5da144b08156b128311b49e01e6fe56..c46fddf07a1b869239000f31635bcc0a23b68adb 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package4.out b/doc/progs/image_package4.out
deleted file mode 100644 (file)
index cb1b777..0000000
+++ /dev/null
@@ -1 +0,0 @@
-image.Point{X:2, Y:1}
index b9e27d6dad523cbd4aa420ef160a25e0599b35f4..0bb5c7608e1a39801afeac17d522d42e22bdb759 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package5.out b/doc/progs/image_package5.out
deleted file mode 100644 (file)
index 2da80c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{255 0 0 255}
index 5e6eefa04a538d5eb8fd3f317d5ef1ab6b31eaa6..62eeecdb9230e35dd53711c94eb392169dd26109 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/image_package6.out b/doc/progs/image_package6.out
deleted file mode 100644 (file)
index fcd13c0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-8 4
-true
index 6972b7287143971d58460837ea637b6ee6c322e0..c2925d590d5659cb3c5a9566a87059f06cd6a484 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index 85e7d51636494e13542612b8109b032daf940357..a541d94e4839815564a68e7f5b7848f1809e8c20 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/interface2.out b/doc/progs/interface2.out
deleted file mode 100644 (file)
index 085bd01..0000000
+++ /dev/null
@@ -1 +0,0 @@
-type: float64
index 887d7d18307b9645f815880873bbed7024d9277e..9e10f4743df7ffe68a80935fadfb8671cf62f89a 100644 (file)
@@ -1,5 +1,3 @@
-// run
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index f358feaa2991871a1e07c7a123223bb5dfd4ffdc..6089ae6710c80181e4fb80218279046a72bbec0d 100644 (file)
@@ -1,5 +1,3 @@
-// cmpout
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/json2.out b/doc/progs/json2.out
deleted file mode 100644 (file)
index 8f2dea5..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-the circle's area 24.227111172875365
-the reciprocal of i is 0.3601008282319049
index 41eb3730c51734888a6ce3c6115cbcae0d2a92e3..a04fdfa506a8dfeec2d6057b4cfc6ab464e492cd 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index ee38f31ad968d986a9eb259cd692714202d05aa5..49263022065fc96b48e86b043377d1ca5ae0d4ba 100644 (file)
@@ -1,5 +1,3 @@
-// run
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index 9ab972df89a9be4bdab722662dda44b302963dfe..6d7a4ca8c47dd3c65638b696c3af8035204ba3ca 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
diff --git a/doc/progs/run b/doc/progs/run
deleted file mode 100755 (executable)
index 6e680b8..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-set -e
-
-goos=$(go env GOOS)
-
-defer_panic_recover="
-       defer
-       defer2
-"
-
-effective_go="
-       eff_bytesize
-       eff_qr
-       eff_sequence
-       eff_unused2
-"
-
-error_handling="
-       error
-       error2
-       error3
-       error4
-"
-
-law_of_reflection="
-       interface
-       interface2
-"
-
-c_go_cgo="
-       cgo1
-       cgo2
-       cgo3
-       cgo4
-"
-# cgo1 and cgo2 don't run on freebsd, srandom has a different signature
-if [ "$goos" == "freebsd" ]; then
-       c_go_cgo="cgo3 cgo4"
-fi
-# cgo1 and cgo2 don't run on netbsd, srandom has a different signature
-# cgo3 and cgo4 don't run on netbsd, since cgo cannot handle stdout correctly
-if [ "$goos" == "netbsd" ]; then
-       c_go_cgo=""
-fi
-# cgo3 and cgo4 don't run on openbsd, since cgo cannot handle stdout correctly
-if [ "$goos" == "openbsd" ]; then
-       c_go_cgo="cgo1 cgo2"
-fi
-if [ "$CGO_ENABLED" != 1 ]; then
-       c_go_cgo=""
-fi
-
-timeout="
-       timeout1
-       timeout2
-"
-
-gobs="
-       gobs1
-       gobs2
-"
-
-json="
-       json1
-       json2
-       json3
-       json4
-       json5
-"
-
-image_package="
-       image_package1
-       image_package2
-       image_package3
-       image_package4
-       image_package5
-       image_package6
-"
-
-all=$(echo $defer_panic_recover $effective_go $error_handling $law_of_reflection $c_go_cgo $timeout $gobs $json $image_package slices go1)
-
-for i in $all; do
-       go build $i.go
-done
-
-# Write to temporary file to avoid mingw bash bug.
-TMPFILE="${TMPDIR:-/tmp}/gotest3.$USER"
-
-function testit {
-       ./$1 >"$TMPFILE" 2>&1 || true
-       x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
-       if ! echo "$x" | grep "$2" > /dev/null
-       then
-               echo $1 failed: '"'$x'"' is not '"'$2'"'
-       fi
-}
-
-
-testit defer '^0 3210 2$'
-testit defer2 '^Calling g. Printing in g 0 Printing in g 1 Printing in g 2 Printing in g 3 Panicking! Defer in g 3 Defer in g 2 Defer in g 1 Defer in g 0 Recovered in f 4 Returned normally from f.$'
-
-testit eff_bytesize '^1.00YB 9.09TB$'
-testit eff_sequence '^\[-1 2 6 16 44\]$'
-
-testit go1 '^Christmas is a holiday: true Sleeping for 0.123s.*go1.go already exists$'
-
-testit interface2 "^type: float64$"
-
-testit json1 "^$"
-testit json2 "the reciprocal of i is"
-testit json3 "Age is int 6"
-testit json4 "^$"
-
-testit image_package1 "^X is 2 Y is 1$"
-testit image_package2 "^3 4 false$"
-testit image_package3 "^3 4 true$"
-testit image_package4 "^image.Point{X:2, Y:1}$"
-testit image_package5 "^{255 0 0 255}$"
-testit image_package6 "^8 4 true$"
-
-rm -f $all "$TMPFILE"
diff --git a/doc/progs/run.go b/doc/progs/run.go
new file mode 100755 (executable)
index 0000000..a664f07
--- /dev/null
@@ -0,0 +1,220 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// run runs the docs tests found in this directory.
+package main
+
+import (
+       "bytes"
+       "flag"
+       "fmt"
+       "os"
+       "os/exec"
+       "regexp"
+       "runtime"
+       "strings"
+)
+
+const usage = `go run run.go [tests]
+
+run.go runs the docs tests in this directory.
+If no tests are provided, it runs all tests.
+Tests may be specified without their .go suffix.
+`
+
+func main() {
+       flag.Usage = func() {
+               fmt.Fprintf(os.Stderr, usage)
+               flag.PrintDefaults()
+               os.Exit(2)
+       }
+
+       flag.Parse()
+       if flag.NArg() == 0 {
+               // run all tests
+               fixcgo()
+       } else {
+               // run specified tests
+               onlyTest(flag.Args()...)
+       }
+
+       // ratec limits the number of tests running concurrently.
+       // None of the tests are intensive, so don't bother
+       // trying to manually adjust for slow builders.
+       ratec := make(chan bool, runtime.NumCPU())
+       errc := make(chan error, len(tests))
+
+       for _, tt := range tests {
+               tt := tt
+               ratec <- true
+               go func() {
+                       errc <- test(tt.file, tt.want)
+                       <-ratec
+               }()
+       }
+
+       var rc int
+       for range tests {
+               if err := <-errc; err != nil {
+                       fmt.Fprintln(os.Stderr, err)
+                       rc = 1
+               }
+       }
+       os.Exit(rc)
+}
+
+// test builds the test in the given file.
+// If want is non-empty, test also runs the test
+// and checks that the output matches the regexp want.
+func test(file, want string) error {
+       // Build the program.
+       cmd := exec.Command("go", "build", file+".go")
+       out, err := cmd.CombinedOutput()
+       if err != nil {
+               return fmt.Errorf("go build %s.go failed: %v\nOutput:\n%s", file, err, out)
+       }
+       defer os.Remove(file)
+
+       // Only run the test if we have output to check.
+       if want == "" {
+               return nil
+       }
+
+       cmd = exec.Command("./" + file)
+       out, err = cmd.CombinedOutput()
+       if err != nil {
+               return fmt.Errorf("./%s failed: %v\nOutput:\n%s", file, err, out)
+       }
+
+       // Canonicalize output.
+       out = bytes.TrimRight(out, "\n")
+       out = bytes.Replace(out, []byte{'\n'}, []byte{' '}, -1)
+
+       // Check the result.
+       match, err := regexp.Match(want, out)
+       if err != nil {
+               return fmt.Errorf("failed to parse regexp %q: %v", want, err)
+       }
+       if !match {
+               return fmt.Errorf("%s.go:\n%q\ndoes not match %s", file, out, want)
+       }
+
+       return nil
+}
+
+type testcase struct {
+       file string
+       want string
+}
+
+var tests = []testcase{
+       // defer_panic_recover
+       {"defer", `^0 3210 2$`},
+       {"defer2", `^Calling g. Printing in g 0 Printing in g 1 Printing in g 2 Printing in g 3 Panicking! Defer in g 3 Defer in g 2 Defer in g 1 Defer in g 0 Recovered in f 4 Returned normally from f.$`},
+
+       // effective_go
+       {"eff_bytesize", `^1.00YB 9.09TB$`},
+       {"eff_qr", ""},
+       {"eff_sequence", `^\[-1 2 6 16 44\]$`},
+       {"eff_unused2", ""},
+
+       // error_handling
+       {"error", ""},
+       {"error2", ""},
+       {"error3", ""},
+       {"error4", ""},
+
+       // law_of_reflection
+       {"interface", ""},
+       {"interface2", `^type: float64$`},
+
+       // c_go_cgo
+       {"cgo1", ""},
+       {"cgo2", ""},
+       {"cgo3", ""},
+       {"cgo4", ""},
+
+       // timeout
+       {"timeout1", ""},
+       {"timeout2", ""},
+
+       // gobs
+       {"gobs1", ""},
+       {"gobs2", ""},
+
+       // json
+       {"json1", `^$`},
+       {"json2", `the reciprocal of i is`},
+       {"json3", `Age is int 6`},
+       {"json4", `^$`},
+       {"json5", ""},
+
+       // image_package
+       {"image_package1", `^X is 2 Y is 1$`},
+       {"image_package2", `^3 4 false$`},
+       {"image_package3", `^3 4 true$`},
+       {"image_package4", `^image.Point{X:2, Y:1}$`},
+       {"image_package5", `^{255 0 0 255}$`},
+       {"image_package6", `^8 4 true$`},
+
+       // other
+       {"go1", `^Christmas is a holiday: true Sleeping for 0.123s.*go1.go already exists$`},
+       {"slices", ""},
+}
+
+func onlyTest(files ...string) {
+       var new []testcase
+NextFile:
+       for _, file := range files {
+               file = strings.TrimSuffix(file, ".go")
+               for _, tt := range tests {
+                       if tt.file == file {
+                               new = append(new, tt)
+                               continue NextFile
+                       }
+               }
+               fmt.Fprintf(os.Stderr, "test %s.go not found\n", file)
+               os.Exit(1)
+       }
+       tests = new
+}
+
+func skipTest(file string) {
+       for i, tt := range tests {
+               if tt.file == file {
+                       copy(tests[i:], tests[i+1:])
+                       tests = tests[:len(tests)-1]
+                       return
+               }
+       }
+       panic("delete(" + file + "): not found")
+}
+
+func fixcgo() {
+       if os.Getenv("CGO_ENABLED") != "1" {
+               skipTest("cgo1")
+               skipTest("cgo2")
+               skipTest("cgo3")
+               skipTest("cgo4")
+               return
+       }
+
+       switch runtime.GOOS {
+       case "freebsd":
+               // cgo1 and cgo2 don't run on freebsd, srandom has a different signature
+               skipTest("cgo1")
+               skipTest("cgo2")
+       case "netbsd":
+               // cgo1 and cgo2 don't run on netbsd, srandom has a different signature
+               skipTest("cgo1")
+               skipTest("cgo2")
+               // cgo3 and cgo4 don't run on netbsd, since cgo cannot handle stdout correctly
+               skipTest("cgo3")
+               skipTest("cgo4")
+       case "openbsd":
+               // cgo3 and cgo4 don't run on openbsd and solaris, since cgo cannot handle stdout correctly
+               skipTest("cgo3")
+               skipTest("cgo4")
+       }
+}
index f9af5feaa05dad607148a2f49a175347206af148..967a3e76bde2dfa3238ad94c0cdbaf03884ce332 100644 (file)
@@ -1,5 +1,3 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index fbc39caac21e651f8d14c1ef6c411fdcc679bb43..353ba6908e5f1a4f152a3e76eadf7ac0baefa28c 100644 (file)
@@ -1,8 +1,7 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package timeout
 
 import (
index a12bc2ab1c8c00863fa23ffaa0bcc35de6f542bb..b0d34eabf8e37468cab71d04c2c76a66a468e110 100644 (file)
@@ -1,8 +1,7 @@
-// compile
-
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
+
 package query
 
 type Conn string
diff --git a/doc/progs/update.bash b/doc/progs/update.bash
deleted file mode 100755 (executable)
index d4ecfbe..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2012 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-set -e
-
-rm -f *.out *.rej *.orig [568].out
-
-for i in *.go; do
-       if grep -q '^// cmpout$' $i; then
-               echo $i
-               go run $i &> ${i/.go/.out}
-       fi
-done
index b0ffdcfbc0e929e68f80370df1ae0eb368dfddfe..e0988b0b8c898b13b8c098491c51024a8d290ba5 100644 (file)
@@ -154,7 +154,7 @@ func (t *tester) registerTests() {
        }
        // ranGoTest and stdMatches are state closed over by the
        // stdlib testing func below. The tests are run sequentially,
-       // so there'no need for locks.
+       // so there'no need for locks.
        var (
                ranGoTest  bool
                stdMatches []string
@@ -280,7 +280,7 @@ func (t *tester) registerTests() {
                }
        }
        if t.hasBash() && t.goos != "nacl" && t.goos != "android" && !iOS {
-               t.registerTest("doc_progs", "../doc/progs", "time", "./run")
+               t.registerTest("doc_progs", "../doc/progs", "time", "go", "run", "run.go")
                t.registerTest("wiki", "../doc/articles/wiki", "./test.bash")
                t.registerTest("codewalk", "../doc/codewalk", "time", "./run")
                t.registerTest("shootout", "../test/bench/shootout", "time", "./timing.sh", "-test")