From fb64aa77f925610ac46c813d080d1f01f3827ece Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 18 May 2021 14:59:01 -0400 Subject: cmd/golangorg: change tests to use internal/webtest Much shorter and clearer. This also opens up the possibility of sharing some tests between TestWeb and TestLiveServer. Change-Id: Iaca004c88581b0e0d8c858333806f755cc140255 Reviewed-on: https://go-review.googlesource.com/c/website/+/321075 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov Website-Publish: Russ Cox --- cmd/golangorg/godoc_test.go | 279 +----------- cmd/golangorg/regtest_test.go | 170 +------- cmd/golangorg/release_test.go | 844 +----------------------------------- cmd/golangorg/testdata/live.txt | 81 ++++ cmd/golangorg/testdata/release.txt | 854 +++++++++++++++++++++++++++++++++++++ cmd/golangorg/testdata/web.txt | 99 +++++ cmd/golangorg/testdata/x.txt | 25 ++ cmd/golangorg/x_test.go | 94 +--- 8 files changed, 1074 insertions(+), 1372 deletions(-) create mode 100644 cmd/golangorg/testdata/live.txt create mode 100644 cmd/golangorg/testdata/release.txt create mode 100644 cmd/golangorg/testdata/web.txt create mode 100644 cmd/golangorg/testdata/x.txt diff --git a/cmd/golangorg/godoc_test.go b/cmd/golangorg/godoc_test.go index a9d5b8bb..1bdbb0f7 100644 --- a/cmd/golangorg/godoc_test.go +++ b/cmd/golangorg/godoc_test.go @@ -10,18 +10,17 @@ package main_test import ( "bytes" "fmt" - "go/build" "io/ioutil" "net" "net/http" "os" "os/exec" "path/filepath" - "regexp" "runtime" - "strings" "testing" "time" + + "golang.org/x/website/internal/webtest" ) // buildGodoc builds the godoc executable. @@ -75,24 +74,12 @@ func waitForServerReady(t *testing.T, addr string) { waitForServer(t, fmt.Sprintf("http://%v/", addr), "The Go Programming Language", - 15*time.Second, - false) -} - -func waitUntilScanComplete(t *testing.T, addr string) { - waitForServer(t, - fmt.Sprintf("http://%v/pkg", addr), - "Scan is not yet complete", - 2*time.Minute, - true, - ) - // setting reverse as true, which means this waits - // until the string is not returned in the response anymore + 15*time.Second) } const pollInterval = 200 * time.Millisecond -func waitForServer(t *testing.T, url, match string, timeout time.Duration, reverse bool) { +func waitForServer(t *testing.T, url, match string, timeout time.Duration) { // "health check" duplicated from x/tools/cmd/tipgodoc/tip.go deadline := time.Now().Add(timeout) for time.Now().Before(deadline) { @@ -104,10 +91,7 @@ func waitForServer(t *testing.T, url, match string, timeout time.Duration, rever rbody, err := ioutil.ReadAll(res.Body) res.Body.Close() if err == nil && res.StatusCode == http.StatusOK { - if bytes.Contains(rbody, []byte(match)) && !reverse { - return - } - if !bytes.Contains(rbody, []byte(match)) && reverse { + if bytes.Contains(rbody, []byte(match)) { return } } @@ -115,17 +99,6 @@ func waitForServer(t *testing.T, url, match string, timeout time.Duration, rever t.Fatalf("Server failed to respond in %v", timeout) } -// 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 killAndWait(cmd *exec.Cmd) { cmd.Process.Kill() cmd.Wait() @@ -165,246 +138,6 @@ func testWeb(t *testing.T) { defer killAndWait(cmd) waitForServerReady(t, addr) - waitUntilScanComplete(t, addr) - tests := []struct { - path string - contains []string // substring - match []string // regexp - notContains []string - redirect string - releaseTag string // optional release tag that must be in go/build.ReleaseTags - }{ - { - path: "/", - contains: []string{ - "Go is an open source programming language", - "Binary distributions available for", - }, - }, - { - path: "/conduct", - contains: []string{"Project Stewards"}, - }, - { - path: "/doc/asm", - contains: []string{"Quick Guide", "Assembler"}, - }, - { - path: "/doc/gdb", - contains: []string{"Debugging Go Code"}, - }, - { - path: "/doc/debugging_with_gdb.html", - redirect: "/doc/gdb", - }, - { - path: "/ref/spec", - contains: []string{"Go Programming Language Specification"}, - }, - { - path: "/doc/go_spec", - redirect: "/ref/spec", - }, - { - path: "/doc/go_spec.html", - redirect: "/ref/spec", - }, - { - path: "/doc/go_spec.md", - redirect: "/ref/spec", - }, - { - path: "/ref/mem", - contains: []string{"Memory Model"}, - }, - { - path: "/doc/go_mem.html", - redirect: "/ref/mem", - }, - { - path: "/doc/go_mem.md", - redirect: "/ref/mem", - }, - { - path: "/doc/help.html", - redirect: "/help", - }, - { - path: "/help/", - redirect: "/help", - }, - { - path: "/help", - contains: []string{"Get help"}, - }, - { - path: "/pkg/fmt/", - contains: []string{"Package fmt implements formatted I/O"}, - }, - { - path: "/src/fmt/", - contains: []string{"scan_test.go"}, - }, - { - path: "/src/fmt/print.go", - contains: []string{"// Println formats using"}, - }, - { - path: "/pkg", - redirect: "/pkg/", - }, - { - path: "/pkg/", - contains: []string{ - "Standard library", - "Package fmt implements formatted I/O", - }, - notContains: []string{ - "internal/syscall", - "cmd/gc", - }, - }, - { - path: "/pkg/?m=all", - contains: []string{ - "Standard library", - "Package fmt implements formatted I/O", - "internal/syscall/?m=all", - }, - notContains: []string{ - "cmd/gc", - }, - }, - { - path: "/pkg/strings/", - contains: []string{ - `href="/src/strings/strings.go"`, - }, - }, - { - path: "/cmd/compile/internal/amd64/", - contains: []string{ - `href="/src/cmd/compile/internal/amd64/ssa.go"`, - }, - }, - { - path: "/pkg/math/bits/", - contains: []string{ - `Added in Go 1.9`, - }, - }, - { - path: "/pkg/net/", - contains: []string{ - `// IPv6 scoped addressing zone; added in Go 1.1`, - }, - }, - { - path: "/pkg/net/http/httptrace/", - match: []string{ - `Got1xxResponse.*// Go 1\.11`, - }, - releaseTag: "go1.11", - }, - // Verify we don't add version info to a struct field added the same time - // as the struct itself: - { - path: "/pkg/net/http/httptrace/", - match: []string{ - `(?m)GotFirstResponseByte func\(\)\s*$`, - }, - }, - // Remove trailing periods before adding semicolons: - { - path: "/pkg/database/sql/", - contains: []string{ - "The number of connections currently in use; added in Go 1.11", - "The number of idle connections; added in Go 1.11", - }, - releaseTag: "go1.11", - }, - { - path: "/project", - contains: []string{ - `
  • Go 1.14 (February 2020)
  • `, - `
  • Go 1.1 (May 2013)
  • `, - }, - }, - { - path: "/doc/go1.16.html", - redirect: "/doc/go1.16", - }, - { - path: "/doc/go1.16", - contains: []string{"Go 1.16"}, - }, - } - for _, test := range tests { - url := fmt.Sprintf("http://%s%s", addr, test.path) - var redirect string - client := &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { - redirect = strings.TrimPrefix(req.URL.String(), "http://"+addr) - return fmt.Errorf("not following redirects") - }, - } - resp, err := client.Get(url) - if redirect != "" { - resp.Body.Close() - if test.redirect == "" { - t.Errorf("GET %s: unexpected redirect -> %s", url, redirect) - continue - } - if test.redirect != redirect { - t.Errorf("GET %s: redirect -> %s, want %s", url, redirect, test.redirect) - continue - } - continue - } - if err != nil { - t.Errorf("GET %s failed: %s", url, err) - continue - } - body, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - if err != nil { - t.Errorf("GET %s: failed to read body: %s (response: %v)", url, err, resp) - } - if test.redirect != "" { - t.Errorf("GET %s: have direct response, want redirect -> %s", url, test.redirect) - } - strBody := string(body) - isErr := false - for _, substr := range test.contains { - if test.releaseTag != "" && !hasTag(test.releaseTag) { - continue - } - if !bytes.Contains(body, []byte(substr)) { - t.Errorf("GET %s: wanted substring %q in body", url, substr) - isErr = true - } - } - for _, re := range test.match { - if test.releaseTag != "" && !hasTag(test.releaseTag) { - continue - } - if ok, err := regexp.MatchString(re, strBody); !ok || err != nil { - if err != nil { - t.Fatalf("Bad regexp %q: %v", re, err) - } - t.Errorf("GET %s: wanted to match %s in body", url, re) - isErr = true - } - } - for _, substr := range test.notContains { - if bytes.Contains(body, []byte(substr)) { - t.Errorf("GET %s: didn't want substring %q in body", url, substr) - isErr = true - } - } - if isErr { - t.Errorf("GET %s: got:\n%s", url, body) - } - } + webtest.TestServer(t, "testdata/web.txt", addr) } diff --git a/cmd/golangorg/regtest_test.go b/cmd/golangorg/regtest_test.go index 38db14b5..fd694cd1 100644 --- a/cmd/golangorg/regtest_test.go +++ b/cmd/golangorg/regtest_test.go @@ -10,15 +10,11 @@ package main_test import ( - "bytes" "flag" - "io" - "io/ioutil" - "net/http" - "net/url" - "regexp" "strings" "testing" + + "golang.org/x/website/internal/webtest" ) var host = flag.String("regtest.host", "", "host to run regression test against") @@ -28,166 +24,6 @@ func TestLiveServer(t *testing.T) { if *host == "" { t.Skip("regtest.host flag missing.") } - substringTests := []struct { - Message string - Path string - Substring string - Regexp string - NoAnalytics bool // expect the response to not contain GA. - PostBody string - StatusCode int // if 0, expect 2xx status code. - }{ - { - Path: "/doc/", - Substring: "an introduction to using modules in a simple project", - }, - { - Path: "/conduct", - Substring: "Project Stewards", - }, - { - Path: "/doc/faq", - Substring: "What is the purpose of the project", - }, - { - Path: "/pkg/", - Substring: "Package tar", - }, - { - Path: "/pkg/os/", - Substring: "func Open", - }, - { - Path: "/pkg/net/http/", - Substring: `title="Added in Go 1.11"`, - Message: "version information not present - failed InitVersionInfo?", - }, - { - Path: "/robots.txt", - Substring: "Disallow: /search", - Message: "robots not present - not deployed from Dockerfile?", - NoAnalytics: true, - }, - { - Path: "/change/75944e2e3a63", - Substring: "bdb10cf", - Message: "no change redirect - hg to git mapping not registered?", - NoAnalytics: true, - StatusCode: 302, - }, - { - Path: "/dl/", - Substring: `href="/dl/go1.11.windows-amd64.msi"`, - Message: "missing data on dl page - misconfiguration of datastore?", - }, - { - Path: "/dl/?mode=json", - Substring: ".windows-amd64.msi", - NoAnalytics: true, - }, - { - Message: "broken shortlinks - misconfiguration of datastore or memcache?", - Path: "/s/go2design", - Regexp: "proposal.*Found", - NoAnalytics: true, - StatusCode: 302, - }, - { - Path: "/compile", - PostBody: "body=" + url.QueryEscape("package main; func main() { print(6*7); }"), - Regexp: `^{"compile_errors":"","output":"42"}$`, - NoAnalytics: true, - }, - { - Path: "/compile", - PostBody: "body=" + url.QueryEscape("//empty"), - Substring: "expected 'package', found 'EOF'", - NoAnalytics: true, - }, - { - Path: "/compile", - PostBody: "version=2&body=package+main%3Bimport+(%22fmt%22%3B%22time%22)%3Bfunc+main()%7Bfmt.Print(%22A%22)%3Btime.Sleep(time.Second)%3Bfmt.Print(%22B%22)%7D", - Regexp: `^{"Errors":"","Events":\[{"Message":"A","Kind":"stdout","Delay":0},{"Message":"B","Kind":"stdout","Delay":1000000000}\]}$`, - NoAnalytics: true, - }, - { - Path: "/share", - PostBody: "package main", - Substring: "", // just check it is a 2xx. - NoAnalytics: true, - }, - { - Path: "/x/net", - Substring: ``, - NoAnalytics: true, - }, - { - Message: "release history page has an entry for Go 1.14.2", - Path: "/doc/devel/release", - Regexp: `go1\.14\.2\s+\(released 2020-04-08\)\s+includes\s+fixes to cgo, the go command, the runtime,`, - }, - { - Message: "Go project page has an entry for Go 1.14", - Path: "/project", - Substring: `
  • Go 1.14 (February 2020)
  • `, - }, - { - Message: "Go project subpath does not exist", - Path: "/project/notexist", - StatusCode: http.StatusNotFound, - }, - } - - for _, tc := range substringTests { - t.Run(tc.Path, func(t *testing.T) { - method := "GET" - var reqBody io.Reader - if tc.PostBody != "" { - method = "POST" - reqBody = strings.NewReader(tc.PostBody) - } - req, err := http.NewRequest(method, *host+tc.Path, reqBody) - if err != nil { - t.Fatalf("NewRequest: %v", err) - } - if reqBody != nil { - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - } - resp, err := http.DefaultTransport.RoundTrip(req) - if err != nil { - t.Fatalf("RoundTrip: %v", err) - } - if tc.StatusCode == 0 { - if resp.StatusCode > 299 { - t.Errorf("Non-OK status code: %v", resp.StatusCode) - } - } else if tc.StatusCode != resp.StatusCode { - t.Errorf("StatusCode; got %v, want %v", resp.StatusCode, tc.StatusCode) - } - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Fatalf("ReadAll: %v", err) - } - const googleAnalyticsID = "UA-11222381-2" // golang.org analytics ID - if !tc.NoAnalytics && !bytes.Contains(body, []byte(googleAnalyticsID)) { - t.Errorf("want response to contain analytics tracking ID") - } - - if tc.Substring != "" { - tc.Regexp = regexp.QuoteMeta(tc.Substring) - } - re := regexp.MustCompile(tc.Regexp) - - if !re.Match(body) { - t.Log("------ actual output -------") - t.Log(string(body)) - t.Log("----------------------------") - if tc.Message != "" { - t.Log(tc.Message) - } - t.Fatalf("wanted response to match %s", tc.Regexp) - } - }) - } + webtest.TestServer(t, "testdata/live.txt", *host) } diff --git a/cmd/golangorg/release_test.go b/cmd/golangorg/release_test.go index 9d44ad78..14917a07 100644 --- a/cmd/golangorg/release_test.go +++ b/cmd/golangorg/release_test.go @@ -8,13 +8,11 @@ package main import ( - "net/http" - "net/http/httptest" - "strings" "testing" "golang.org/x/website" "golang.org/x/website/internal/web" + "golang.org/x/website/internal/webtest" ) // Test that the release history page includes expected entries. @@ -34,843 +32,5 @@ func TestReleaseHistory(t *testing.T) { } mux := registerHandlers(site) - req := httptest.NewRequest(http.MethodGet, "/doc/devel/release", nil) - rr := httptest.NewRecorder() - mux.ServeHTTP(rr, req) - resp := rr.Result() - if got, want := resp.StatusCode, http.StatusOK; got != want { - t.Errorf("got status code %d %s, want %d %s", got, http.StatusText(got), want, http.StatusText(want)) - } - if got, want := resp.Header.Get("Content-Type"), "text/html; charset=utf-8"; got != want { - t.Errorf("got Content-Type header %q, want %q", got, want) - } - if !strings.Contains(foldSpace(rr.Body.String()), foldSpace(wantGo114HTML)) { - t.Errorf("got body that doesn't contain expected Go 1.14 release history entries") - println("HAVE") - println(rr.Body.String()) - println("WANT") - println(wantGo114HTML) - } - if !strings.Contains(foldSpace(rr.Body.String()), foldSpace(wantGo113HTML)) { - t.Errorf("got body that doesn't contain expected Go 1.13 release history entries") - } - if !strings.Contains(foldSpace(rr.Body.String()), foldSpace(wantOldReleaseHTML)) { - t.Errorf("got body that doesn't contain expected Go 1.12 and older release history entries") - } + webtest.TestHandler(t, "testdata/release.txt", mux) } - -// foldSpace returns s with each instance of one or more consecutive -// white space characters, as defined by unicode.IsSpace, replaced -// by a single space ('\x20') character, with leading and trailing -// white space removed. -func foldSpace(s string) string { - return strings.Join(strings.Fields(s), " ") -} - -const wantGo114HTML = ` -

    go1.14 (released 2020-02-25)

    - -

    -Go 1.14 is a major release of Go. -Read the Go 1.14 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.14.1 (released 2020-03-19) includes fixes to the go command, tools, and the runtime. See the -Go -1.14.1 milestone on our issue tracker for details. -

    - -

    -go1.14.2 (released 2020-04-08) includes fixes to cgo, the go command, the runtime, -and the os/exec and testing packages. See the -Go -1.14.2 milestone on our issue tracker for details. -

    -` - -const wantGo113HTML = ` -

    go1.13 (released 2019-09-03)

    - -

    -Go 1.13 is a major release of Go. -Read the Go 1.13 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.13.1 (released 2019-09-25) includes security fixes to the -net/http and net/textproto packages. -See the Go -1.13.1 milestone on our issue tracker for details. -

    - -

    -go1.13.2 (released 2019-10-17) includes security fixes to the -compiler and the crypto/dsa package. -See the Go -1.13.2 milestone on our issue tracker for details. -

    - -

    -go1.13.3 (released 2019-10-17) includes fixes to the go command, -the toolchain, the runtime, and the syscall, net, -net/http, and crypto/ecdsa packages. -See the Go -1.13.3 milestone on our issue tracker for details. -

    - -

    -go1.13.4 (released 2019-10-31) includes fixes to the net/http and -syscall packages. It also fixes an issue on macOS 10.15 Catalina -where the non-notarized installer and binaries were being -rejected by Gatekeeper. -See the Go -1.13.4 milestone on our issue tracker for details. -

    - -

    -go1.13.5 (released 2019-12-04) includes fixes to the go command, the runtime, -the linker, and the net/http package. See the -Go -1.13.5 milestone on our issue tracker for details. -

    - -

    -go1.13.6 (released 2020-01-09) includes fixes to the runtime and -the net/http package. See -the Go -1.13.6 milestone on our issue tracker for details. -

    - -

    -go1.13.7 (released 2020-01-28) includes two security fixes to -the crypto/x509 package. See the -Go -1.13.7 milestone on our issue tracker for details. -

    - -

    -go1.13.8 (released 2020-02-12) includes fixes to the runtime, and the -crypto/x509 and net/http packages. See the -Go -1.13.8 milestone on our issue tracker for details. -

    - -

    -go1.13.9 (released 2020-03-19) includes fixes to the go command, tools, the runtime, the -toolchain, and the crypto/cypher package. See the -Go -1.13.9 milestone on our issue tracker for details. -

    - -

    -go1.13.10 (released 2020-04-08) includes fixes to the go command, the runtime, -and the os/exec and time packages. See the -Go -1.13.10 milestone on our issue tracker for details. -

    -` - -const wantOldReleaseHTML = ` -

    go1.12 (released 2019-02-25)

    - -

    -Go 1.12 is a major release of Go. -Read the Go 1.12 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.12.1 (released 2019-03-14) includes fixes to cgo, the compiler, the go -command, and the fmt, net/smtp, os, -path/filepath, sync, and text/template -packages. See the Go -1.12.1 milestone on our issue tracker for details. -

    - -

    -go1.12.2 (released 2019-04-05) includes fixes to the compiler, the go -command, the runtime, and the doc, net, -net/http/httputil, and os packages. See the -Go -1.12.2 milestone on our issue tracker for details. -

    - -

    -go1.12.3 (released 2019-04-08) was accidentally released without its -intended fix. It is identical to go1.12.2, except for its version -number. The intended fix is in go1.12.4. -

    - -

    -go1.12.4 (released 2019-04-11) fixes an issue where using the prebuilt binary -releases on older versions of GNU/Linux -led to failures -when linking programs that used cgo. -Only Linux users who hit this issue need to update. -

    - -

    -go1.12.5 (released 2019-05-06) includes fixes to the compiler, the linker, -the go command, the runtime, and the os package. See the -Go -1.12.5 milestone on our issue tracker for details. -

    - -

    -go1.12.6 (released 2019-06-11) includes fixes to the compiler, the linker, -the go command, and the crypto/x509, net/http, and -os packages. See the -Go -1.12.6 milestone on our issue tracker for details. -

    - -

    -go1.12.7 (released 2019-07-08) includes fixes to cgo, the compiler, -and the linker. -See the Go -1.12.7 milestone on our issue tracker for details. -

    - -

    -go1.12.8 (released 2019-08-13) includes security fixes to the -net/http and net/url packages. -See the Go -1.12.8 milestone on our issue tracker for details. -

    - -

    -go1.12.9 (released 2019-08-15) includes fixes to the linker, -and the os and math/big packages. -See the Go -1.12.9 milestone on our issue tracker for details. -

    - -

    -go1.12.10 (released 2019-09-25) includes security fixes to the -net/http and net/textproto packages. -See the Go -1.12.10 milestone on our issue tracker for details. -

    - -

    -go1.12.11 (released 2019-10-17) includes security fixes to the -crypto/dsa package. -See the Go -1.12.11 milestone on our issue tracker for details. -

    - -

    -go1.12.12 (released 2019-10-17) includes fixes to the go command, -runtime, and the syscall and net packages. -See the Go -1.12.12 milestone on our issue tracker for details. -

    - -

    -go1.12.13 (released 2019-10-31) fixes an issue on macOS 10.15 Catalina -where the non-notarized installer and binaries were being -rejected by Gatekeeper. -Only macOS users who hit this issue need to update. -

    - -

    -go1.12.14 (released 2019-12-04) includes a fix to the runtime. See -the Go -1.12.14 milestone on our issue tracker for details. -

    - -

    -go1.12.15 (released 2020-01-09) includes fixes to the runtime and -the net/http package. See -the Go -1.12.15 milestone on our issue tracker for details. -

    - -

    -go1.12.16 (released 2020-01-28) includes two security fixes to -the crypto/x509 package. See the -Go -1.12.16 milestone on our issue tracker for details. -

    - -

    -go1.12.17 (released 2020-02-12) includes a fix to the runtime. See -the Go -1.12.17 milestone on our issue tracker for details. -

    - -

    go1.11 (released 2018-08-24)

    - -

    -Go 1.11 is a major release of Go. -Read the Go 1.11 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.11.1 (released 2018-10-01) includes fixes to the compiler, documentation, go -command, runtime, and the crypto/x509, encoding/json, -go/types, net, net/http, and -reflect packages. -See the Go -1.11.1 milestone on our issue tracker for details. -

    - -

    -go1.11.2 (released 2018-11-02) includes fixes to the compiler, linker, -documentation, go command, and the database/sql and -go/types packages. -See the Go -1.11.2 milestone on our issue tracker for details. -

    - -

    -go1.11.3 (released 2018-12-12) includes three security fixes to "go get" and -the crypto/x509 package. -See the Go -1.11.3 milestone on our issue tracker for details. -

    - -

    -go1.11.4 (released 2018-12-14) includes fixes to cgo, the compiler, linker, -runtime, documentation, go command, and the net/http and -go/types packages. -It includes a fix to a bug introduced in Go 1.11.3 that broke go -get for import path patterns containing "...". -See the Go -1.11.4 milestone on our issue tracker for details. -

    - -

    -go1.11.5 (released 2019-01-23) includes a security fix to the -crypto/elliptic package. See -the Go -1.11.5 milestone on our issue tracker for details. -

    - -

    -go1.11.6 (released 2019-03-14) includes fixes to cgo, the compiler, linker, -runtime, go command, and the crypto/x509, encoding/json, -net, and net/url packages. See the -Go -1.11.6 milestone on our issue tracker for details. -

    - -

    -go1.11.7 (released 2019-04-05) includes fixes to the runtime and the -net package. See the -Go -1.11.7 milestone on our issue tracker for details. -

    - -

    -go1.11.8 (released 2019-04-08) was accidentally released without its -intended fix. It is identical to go1.11.7, except for its version -number. The intended fix is in go1.11.9. -

    - -

    -go1.11.9 (released 2019-04-11) fixes an issue where using the prebuilt binary -releases on older versions of GNU/Linux -led to failures -when linking programs that used cgo. -Only Linux users who hit this issue need to update. -

    - -

    -go1.11.10 (released 2019-05-06) includes fixes to the runtime and the linker. -See the Go -1.11.10 milestone on our issue tracker for details. -

    - -

    -go1.11.11 (released 2019-06-11) includes a fix to the crypto/x509 package. -See the Go -1.11.11 milestone on our issue tracker for details. -

    - -

    -go1.11.12 (released 2019-07-08) includes fixes to the compiler and the linker. -See the Go -1.11.12 milestone on our issue tracker for details. -

    - -

    -go1.11.13 (released 2019-08-13) includes security fixes to the -net/http and net/url packages. -See the Go -1.11.13 milestone on our issue tracker for details. -

    - -

    go1.10 (released 2018-02-16)

    - -

    -Go 1.10 is a major release of Go. -Read the Go 1.10 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.10.1 (released 2018-03-28) includes fixes to the compiler, runtime, and the -archive/zip, crypto/tls, crypto/x509, -encoding/json, net, net/http, and -net/http/pprof packages. -See the Go -1.10.1 milestone on our issue tracker for details. -

    - -

    -go1.10.2 (released 2018-05-01) includes fixes to the compiler, linker, and go -command. -See the Go -1.10.2 milestone on our issue tracker for details. -

    - -

    -go1.10.3 (released 2018-06-05) includes fixes to the go command, and the -crypto/tls, crypto/x509, and strings packages. -In particular, it adds -minimal support to the go command for the vgo transition. -See the Go -1.10.3 milestone on our issue tracker for details. -

    - -

    -go1.10.4 (released 2018-08-24) includes fixes to the go command, linker, and the -net/http, mime/multipart, ld/macho, -bytes, and strings packages. -See the Go -1.10.4 milestone on our issue tracker for details. -

    - -

    -go1.10.5 (released 2018-11-02) includes fixes to the go command, linker, runtime, -and the database/sql package. -See the Go -1.10.5 milestone on our issue tracker for details. -

    - -

    -go1.10.6 (released 2018-12-12) includes three security fixes to "go get" and -the crypto/x509 package. -It contains the same fixes as Go 1.11.3 and was released at the same time. -See the Go -1.10.6 milestone on our issue tracker for details. -

    - -

    -go1.10.7 (released 2018-12-14) includes a fix to a bug introduced in Go 1.10.6 -that broke go get for import path patterns containing -"...". -See the -Go 1.10.7 milestone on our issue tracker for details. -

    - -

    -go1.10.8 (released 2019-01-23) includes a security fix to the -crypto/elliptic package. See -the Go -1.10.8 milestone on our issue tracker for details. -

    - -

    go1.9 (released 2017-08-24)

    - -

    -Go 1.9 is a major release of Go. -Read the Go 1.9 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.9.1 (released 2017-10-04) includes two security fixes. -See the Go -1.9.1 milestone on our issue tracker for details. -

    - -

    -go1.9.2 (released 2017-10-25) includes fixes to the compiler, linker, runtime, -documentation, go command, -and the crypto/x509, database/sql, log, -and net/smtp packages. -It includes a fix to a bug introduced in Go 1.9.1 that broke go get -of non-Git repositories under certain conditions. -See the Go -1.9.2 milestone on our issue tracker for details. -

    - -

    -go1.9.3 (released 2018-01-22) includes fixes to the compiler, runtime, -and the database/sql, math/big, net/http, -and net/url packages. -See the Go -1.9.3 milestone on our issue tracker for details. -

    - -

    -go1.9.4 (released 2018-02-07) includes a security fix to "go get". -See the Go -1.9.4 milestone on our issue tracker for details. -

    - -

    -go1.9.5 (released 2018-03-28) includes fixes to the compiler, go command, and the -net/http/pprof package. -See the Go -1.9.5 milestone on our issue tracker for details. -

    - -

    -go1.9.6 (released 2018-05-01) includes fixes to the compiler and go command. -See the Go -1.9.6 milestone on our issue tracker for details. -

    - -

    -go1.9.7 (released 2018-06-05) includes fixes to the go command, and the -crypto/x509 and strings packages. -In particular, it adds -minimal support to the go command for the vgo transition. -See the Go -1.9.7 milestone on our issue tracker for details. -

    - -

    go1.8 (released 2017-02-16)

    - -

    -Go 1.8 is a major release of Go. -Read the Go 1.8 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.8.1 (released 2017-04-07) includes fixes to the compiler, linker, runtime, -documentation, go command and the crypto/tls, -encoding/xml, image/png, net, -net/http, reflect, text/template, -and time packages. -See the Go -1.8.1 milestone on our issue tracker for details. -

    - -

    -go1.8.2 (released 2017-05-23) includes a security fix to the -crypto/elliptic package. -See the Go -1.8.2 milestone on our issue tracker for details. -

    - -

    -go1.8.3 (released 2017-05-24) includes fixes to the compiler, runtime, -documentation, and the database/sql package. -See the Go -1.8.3 milestone on our issue tracker for details. -

    - -

    -go1.8.4 (released 2017-10-04) includes two security fixes. -It contains the same fixes as Go 1.9.1 and was released at the same time. -See the Go -1.8.4 milestone on our issue tracker for details. -

    - -

    -go1.8.5 (released 2017-10-25) includes fixes to the compiler, linker, runtime, -documentation, go command, -and the crypto/x509 and net/smtp packages. -It includes a fix to a bug introduced in Go 1.8.4 that broke go get -of non-Git repositories under certain conditions. -See the Go -1.8.5 milestone on our issue tracker for details. -

    - -

    -go1.8.6 (released 2018-01-22) includes the same fix in math/big -as Go 1.9.3 and was released at the same time. -See the Go -1.8.6 milestone on our issue tracker for details. -

    - -

    -go1.8.7 (released 2018-02-07) includes a security fix to "go get". -It contains the same fix as Go 1.9.4 and was released at the same time. -See the Go -1.8.7 milestone on our issue tracker for details. -

    - -

    go1.7 (released 2016-08-15)

    - -

    -Go 1.7 is a major release of Go. -Read the Go 1.7 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.7.1 (released 2016-09-07) includes fixes to the compiler, runtime, -documentation, and the compress/flate, hash/crc32, -io, net, net/http, -path/filepath, reflect, and syscall -packages. -See the Go -1.7.1 milestone on our issue tracker for details. -

    - -

    -go1.7.2 should not be used. It was tagged but not fully released. -The release was deferred due to a last minute bug report. -Use go1.7.3 instead, and refer to the summary of changes below. -

    - -

    -go1.7.3 (released 2016-10-19) includes fixes to the compiler, runtime, -and the crypto/cipher, crypto/tls, -net/http, and strings packages. -See the Go -1.7.3 milestone on our issue tracker for details. -

    - -

    -go1.7.4 (released 2016-12-01) includes two security fixes. -See the Go -1.7.4 milestone on our issue tracker for details. -

    - -

    -go1.7.5 (released 2017-01-26) includes fixes to the compiler, runtime, -and the crypto/x509 and time packages. -See the Go -1.7.5 milestone on our issue tracker for details. -

    - -

    -go1.7.6 (released 2017-05-23) includes the same security fix as Go 1.8.2 and -was released at the same time. -See the Go -1.8.2 milestone on our issue tracker for details. -

    - -

    go1.6 (released 2016-02-17)

    - -

    -Go 1.6 is a major release of Go. -Read the Go 1.6 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.6.1 (released 2016-04-12) includes two security fixes. -See the Go -1.6.1 milestone on our issue tracker for details. -

    - -

    -go1.6.2 (released 2016-04-20) includes fixes to the compiler, runtime, tools, -documentation, and the mime/multipart, net/http, and -sort packages. -See the Go -1.6.2 milestone on our issue tracker for details. -

    - -

    -go1.6.3 (released 2016-07-17) includes security fixes to the -net/http/cgi package and net/http package when used in -a CGI environment. -See the Go -1.6.3 milestone on our issue tracker for details. -

    - -

    -go1.6.4 (released 2016-12-01) includes two security fixes. -It contains the same fixes as Go 1.7.4 and was released at the same time. -See the Go -1.7.4 milestone on our issue tracker for details. -

    - -

    go1.5 (released 2015-08-19)

    - -

    -Go 1.5 is a major release of Go. -Read the Go 1.5 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.5.1 (released 2015-09-08) includes bug fixes to the compiler, assembler, and -the fmt, net/textproto, net/http, and -runtime packages. -See the Go -1.5.1 milestone on our issue tracker for details. -

    - -

    -go1.5.2 (released 2015-12-02) includes bug fixes to the compiler, linker, and -the mime/multipart, net, and runtime -packages. -See the Go -1.5.2 milestone on our issue tracker for details. -

    - -

    -go1.5.3 (released 2016-01-13) includes a security fix to the math/big package -affecting the crypto/tls package. -See the release announcement for details. -

    - -

    -go1.5.4 (released 2016-04-12) includes two security fixes. -It contains the same fixes as Go 1.6.1 and was released at the same time. -See the Go -1.6.1 milestone on our issue tracker for details. -

    - -

    go1.4 (released 2014-12-10)

    - -

    -Go 1.4 is a major release of Go. -Read the Go 1.4 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.4.1 (released 2015-01-15) includes bug fixes to the linker and the log, syscall, and runtime packages. -See the Go 1.4.1 milestone on our issue tracker for details. -

    - -

    -go1.4.2 (released 2015-02-17) includes bug fixes to the go command, the compiler and linker, and the runtime, syscall, reflect, and math/big packages. -See the Go 1.4.2 milestone on our issue tracker for details. -

    - -

    -go1.4.3 (released 2015-09-22) includes security fixes to the net/http package and bug fixes to the runtime package. -See the Go 1.4.3 milestone on our issue tracker for details. -

    - -

    go1.3 (released 2014-06-18)

    - -

    -Go 1.3 is a major release of Go. -Read the Go 1.3 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.3.1 (released 2014-08-13) includes bug fixes to the compiler and the runtime, net, and crypto/rsa packages. -See the change history for details. -

    - -

    -go1.3.2 (released 2014-09-25) includes bug fixes to cgo and the crypto/tls packages. -See the change history for details. -

    - -

    -go1.3.3 (released 2014-09-30) includes further bug fixes to cgo, the runtime package, and the nacl port. -See the change history for details. -

    - -

    go1.2 (released 2013-12-01)

    - -

    -Go 1.2 is a major release of Go. -Read the Go 1.2 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.2.1 (released 2014-03-02) includes bug fixes to the runtime, net, and database/sql packages. -See the change history for details. -

    - -

    -go1.2.2 (released 2014-05-05) includes a -security fix -that affects the tour binary included in the binary distributions (thanks to Guillaume T). -

    - -

    go1.1 (released 2013-05-13)

    - -

    -Go 1.1 is a major release of Go. -Read the Go 1.1 Release Notes for more information. -

    - -

    Minor revisions

    - -

    -go1.1.1 (released 2013-06-13) includes several compiler and runtime bug fixes. -See the change history for details. -

    - -

    -go1.1.2 (released 2013-08-13) includes fixes to the gc compiler -and cgo, and the bufio, runtime, -syscall, and time packages. -See the change history for details. -If you use package syscall's Getrlimit and Setrlimit -functions under Linux on the ARM or 386 architectures, please note change -11803043 -that fixes issue 5949. -

    - -

    go1 (released 2012-03-28)

    - -

    -Go 1 is a major release of Go that will be stable in the long term. -Read the Go 1 Release Notes for more information. -

    - -

    -It is intended that programs written for Go 1 will continue to compile and run -correctly, unchanged, under future versions of Go 1. -Read the Go 1 compatibility document for more -about the future of Go 1. -

    - -

    -The go1 release corresponds to -weekly.2012-03-27. -

    - -

    Minor revisions

    - -

    -go1.0.1 (released 2012-04-25) was issued to -fix an -escape analysis bug -that can lead to memory corruption. -It also includes several minor code and documentation fixes. -

    - -

    -go1.0.2 (released 2012-06-13) was issued to fix two bugs in the implementation -of maps using struct or array keys: -issue 3695 and -issue 3573. -It also includes many minor code and documentation fixes. -

    - -

    -go1.0.3 (released 2012-09-21) includes minor code and documentation fixes. -

    - -

    -See the go1 release branch history for the complete list of changes. -

    -` diff --git a/cmd/golangorg/testdata/live.txt b/cmd/golangorg/testdata/live.txt new file mode 100644 index 00000000..02c0e4ea --- /dev/null +++ b/cmd/golangorg/testdata/live.txt @@ -0,0 +1,81 @@ +GET /doc/ +body contains an introduction to using modules in a simple project + +GET /conduct +body contains Project Stewards + +GET /doc/devel/release +body ~ go1\.14\.2\s+\(released 2020-04-08\)\s+includes\s+fixes to cgo, the go command, the runtime, + +GET /doc/devel/release.html +redirect == /doc/devel/release + +GET /doc/faq +body contains What is the purpose of the project + +GET /pkg/ +body contains Package tar + +GET /pkg/os/ +body contains func Open + +GET /pkg/net/http/ +body contains title="Added in Go 1.11" + +GET /robots.txt +body contains Disallow: /search +body !contains UA- + +GET /change/75944e2e3a63 +code == 302 +redirect contains bdb10cf +body contains bdb10cf +body !contains UA- + +GET /dl/ +body contains href="/dl/go1.11.windows-amd64.msi" + +GET /dl/?mode=json +body contains .windows-amd64.msi +body !contains UA- + +GET /s/go2design +code == 302 +body ~ proposal.*Found +body !contains UA- + +POST /compile +postquery + body=package main; func main() { print(6*7); } +body == {"compile_errors":"","output":"42"} + +POST /compile +postquery + body=//empty +body contains expected 'package', found 'EOF' +body !contains UA- + +POST /compile +postquery + version=2 + body=package main; import ("fmt"; "time"); func main() {fmt.Print("A"); time.Sleep(time.Second); fmt.Print("B")} +body == {"Errors":"","Events":[{"Message":"A","Kind":"stdout","Delay":0},{"Message":"B","Kind":"stdout","Delay":1000000000}]} + +POST /share +postbody + package main +body !contains UA- + +GET /x/net +code == 200 +body contains +body !contains UA- + +GET /project +body contains
  • Go 1.14 (February 2020)
  • + +GET /project/ +redirect == /project + +GET /project/notexist +code == 404 diff --git a/cmd/golangorg/testdata/release.txt b/cmd/golangorg/testdata/release.txt new file mode 100644 index 00000000..5724f4f7 --- /dev/null +++ b/cmd/golangorg/testdata/release.txt @@ -0,0 +1,854 @@ +GET /doc/devel/release +header content-type == text/html; charset=utf-8 +trimbody contains +

    go1.14 (released 2020-02-25)

    +

    + Go 1.14 is a major release of Go. + Read the Go 1.14 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.14.1 + (released 2020-03-19) + includes + fixes to the go command, tools, and the runtime. + See the + Go 1.14.1 milestone + on our issue tracker for details. +

    +

    + go1.14.2 + (released 2020-04-08) + includes + fixes to cgo, the go command, the runtime, and the os/exec and testing packages. + See the + Go 1.14.2 milestone + on our issue tracker for details. +

    +trimbody contains +

    go1.13 (released 2019-09-03)

    +

    + Go 1.13 is a major release of Go. + Read the Go 1.13 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.13.1 + (released 2019-09-25) + includes + security + fixes to the net/http and net/textproto packages. + See the + Go 1.13.1 milestone + on our issue tracker for details. +

    +

    + go1.13.2 + (released 2019-10-17) + includes + security + fixes to the compiler and the crypto/dsa package. + See the + Go 1.13.2 milestone + on our issue tracker for details. +

    +

    + go1.13.3 + (released 2019-10-17) + includes + fixes to the go command, the toolchain, the runtime, and the syscall, net, net/http, and crypto/ecdsa packages. + See the + Go 1.13.3 milestone + on our issue tracker for details. +

    +

    + go1.13.4 + (released 2019-10-31) + includes + fixes to the net/http and syscall packages. + It also fixes an issue on macOS 10.15 Catalina + where the non-notarized installer and binaries were being + rejected by Gatekeeper. + See the + Go 1.13.4 milestone + on our issue tracker for details. +

    +

    + go1.13.5 + (released 2019-12-04) + includes + fixes to the go command, the runtime, the linker, and the net/http package. + See the + Go 1.13.5 milestone + on our issue tracker for details. +

    +

    + go1.13.6 + (released 2020-01-09) + includes + fixes to the runtime and the net/http package. + See the + Go 1.13.6 milestone + on our issue tracker for details. +

    +

    + go1.13.7 + (released 2020-01-28) + includes + two + security + fixes to the crypto/x509 package. + See the + Go 1.13.7 milestone + on our issue tracker for details. +

    +

    + go1.13.8 + (released 2020-02-12) + includes + fixes to the runtime, and the crypto/x509 and net/http packages. + See the + Go 1.13.8 milestone + on our issue tracker for details. +

    +

    + go1.13.9 + (released 2020-03-19) + includes + fixes to the go command, tools, the runtime, the toolchain, and the crypto/cypher package. + See the + Go 1.13.9 milestone + on our issue tracker for details. +

    +

    + go1.13.10 + (released 2020-04-08) + includes + fixes to the go command, the runtime, and the os/exec and time packages. + See the + Go 1.13.10 milestone + on our issue tracker for details. +

    +

    +trimbody contains +

    go1.12 (released 2019-02-25)

    +

    + Go 1.12 is a major release of Go. + Read the Go 1.12 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.12.1 + (released 2019-03-14) + includes + fixes to cgo, the compiler, the go command, and the fmt, net/smtp, os, path/filepath, sync, and text/template packages. + See the + Go 1.12.1 milestone + on our issue tracker for details. +

    +

    + go1.12.2 + (released 2019-04-05) + includes + fixes to the compiler, the go command, the runtime, and the doc, net, net/http/httputil, and os packages. + See the + Go 1.12.2 milestone + on our issue tracker for details. +

    +

    + go1.12.3 + (released 2019-04-08) + was accidentally released without its + intended fix. It is identical to go1.12.2, except for its version + number. The intended fix is in go1.12.4. +

    +

    + go1.12.4 + (released 2019-04-11) + fixes an issue where using the prebuilt binary + releases on older versions of GNU/Linux + led to failures + when linking programs that used cgo. + Only Linux users who hit this issue need to update. +

    +

    + go1.12.5 + (released 2019-05-06) + includes + fixes to the compiler, the linker, the go command, the runtime, and the os package. + See the + Go 1.12.5 milestone + on our issue tracker for details. +

    +

    + go1.12.6 + (released 2019-06-11) + includes + fixes to the compiler, the linker, the go command, and the crypto/x509, net/http, and os packages. + See the + Go 1.12.6 milestone + on our issue tracker for details. +

    +

    + go1.12.7 + (released 2019-07-08) + includes + fixes to cgo, the compiler, and the linker. + See the + Go 1.12.7 milestone + on our issue tracker for details. +

    +

    + go1.12.8 + (released 2019-08-13) + includes + security + fixes to the net/http and net/url packages. + See the + Go 1.12.8 milestone + on our issue tracker for details. +

    +

    + go1.12.9 + (released 2019-08-15) + includes + fixes to the linker, and the os and math/big packages. + See the + Go 1.12.9 milestone + on our issue tracker for details. +

    +

    + go1.12.10 + (released 2019-09-25) + includes + security + fixes to the net/http and net/textproto packages. + See the + Go 1.12.10 milestone + on our issue tracker for details. +

    +

    + go1.12.11 + (released 2019-10-17) + includes + security + fixes to the crypto/dsa package. + See the + Go 1.12.11 milestone + on our issue tracker for details. +

    +

    + go1.12.12 + (released 2019-10-17) + includes + fixes to the go command, runtime, and the syscall and net packages. + See the + Go 1.12.12 milestone + on our issue tracker for details. +

    +

    + go1.12.13 + (released 2019-10-31) + fixes an issue on macOS 10.15 Catalina + where the non-notarized installer and binaries were being + rejected by Gatekeeper. + Only macOS users who hit this issue need to update. +

    +

    + go1.12.14 + (released 2019-12-04) + includes + a + fix to the runtime. + See the + Go 1.12.14 milestone + on our issue tracker for details. +

    +

    + go1.12.15 + (released 2020-01-09) + includes + fixes to the runtime and the net/http package. + See the + Go 1.12.15 milestone + on our issue tracker for details. +

    +

    + go1.12.16 + (released 2020-01-28) + includes + two + security + fixes to the crypto/x509 package. + See the + Go 1.12.16 milestone + on our issue tracker for details. +

    +

    + go1.12.17 + (released 2020-02-12) + includes + a + fix to the runtime. + See the + Go 1.12.17 milestone + on our issue tracker for details. +

    +

    go1.11 (released 2018-08-24)

    +

    + Go 1.11 is a major release of Go. + Read the Go 1.11 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.11.1 + (released 2018-10-01) + includes + fixes to the compiler, documentation, go command, runtime, and the crypto/x509, encoding/json, go/types, net, net/http, and reflect packages. + See the + Go 1.11.1 milestone + on our issue tracker for details. +

    +

    + go1.11.2 + (released 2018-11-02) + includes + fixes to the compiler, linker, documentation, go command, and the database/sql and go/types packages. + See the + Go 1.11.2 milestone + on our issue tracker for details. +

    +

    + go1.11.3 + (released 2018-12-12) + includes + three + security + fixes to "go get" and the crypto/x509 package. + See the + Go 1.11.3 milestone + on our issue tracker for details. +

    +

    + go1.11.4 + (released 2018-12-14) + includes + fixes to cgo, the compiler, linker, runtime, documentation, go command, and the net/http and go/types packages. + It includes a fix to a bug introduced in Go 1.11.3 that broke go + get for import path patterns containing "...". + See the + Go 1.11.4 milestone + on our issue tracker for details. +

    +

    + go1.11.5 + (released 2019-01-23) + includes + a + security + fix to the crypto/elliptic package. + See the + Go 1.11.5 milestone + on our issue tracker for details. +

    +

    + go1.11.6 + (released 2019-03-14) + includes + fixes to cgo, the compiler, linker, runtime, go command, and the crypto/x509, encoding/json, net, and net/url packages. + See the + Go 1.11.6 milestone + on our issue tracker for details. +

    +

    + go1.11.7 + (released 2019-04-05) + includes + fixes to the runtime and the net package. + See the + Go 1.11.7 milestone + on our issue tracker for details. +

    +

    + go1.11.8 + (released 2019-04-08) + was accidentally released without its + intended fix. It is identical to go1.11.7, except for its version + number. The intended fix is in go1.11.9. +

    +

    + go1.11.9 + (released 2019-04-11) + fixes an issue where using the prebuilt binary + releases on older versions of GNU/Linux + led to failures + when linking programs that used cgo. + Only Linux users who hit this issue need to update. +

    +

    + go1.11.10 + (released 2019-05-06) + includes + fixes to the runtime and the linker. + See the + Go 1.11.10 milestone + on our issue tracker for details. +

    +

    + go1.11.11 + (released 2019-06-11) + includes + a + fix to the crypto/x509 package. + See the + Go 1.11.11 milestone + on our issue tracker for details. +

    +

    + go1.11.12 + (released 2019-07-08) + includes + fixes to the compiler and the linker. + See the + Go 1.11.12 milestone + on our issue tracker for details. +

    +

    + go1.11.13 + (released 2019-08-13) + includes + security + fixes to the net/http and net/url packages. + See the + Go 1.11.13 milestone + on our issue tracker for details. +

    +

    go1.10 (released 2018-02-16)

    +

    + Go 1.10 is a major release of Go. + Read the Go 1.10 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.10.1 + (released 2018-03-28) + includes + fixes to the compiler, runtime, and the archive/zip, crypto/tls, crypto/x509, encoding/json, net, net/http, and net/http/pprof packages. + See the + Go 1.10.1 milestone + on our issue tracker for details. +

    +

    + go1.10.2 + (released 2018-05-01) + includes + fixes to the compiler, linker, and go command. + See the + Go 1.10.2 milestone + on our issue tracker for details. +

    +

    + go1.10.3 + (released 2018-06-05) + includes + fixes to the go command, and the crypto/tls, crypto/x509, and strings packages. + In particular, it adds + minimal support to the go command for the vgo transition. + See the + Go 1.10.3 milestone + on our issue tracker for details. +

    +

    + go1.10.4 + (released 2018-08-24) + includes + fixes to the go command, linker, and the net/http, mime/multipart, ld/macho, bytes, and strings packages. + See the + Go 1.10.4 milestone + on our issue tracker for details. +

    +

    + go1.10.5 + (released 2018-11-02) + includes + fixes to the go command, linker, runtime, and the database/sql package. + See the + Go 1.10.5 milestone + on our issue tracker for details. +

    +

    + go1.10.6 + (released 2018-12-12) + includes + three + security + fixes to "go get" and the crypto/x509 package. + It contains the same fixes as Go 1.11.3 and was released at the same time. + See the + Go 1.10.6 milestone + on our issue tracker for details. +

    +

    + go1.10.7 + (released 2018-12-14) + includes a fix to a bug introduced in Go 1.10.6 + that broke go get for import path patterns containing + "...". + See the + Go 1.10.7 milestone on our issue tracker for details. +

    +

    + go1.10.8 + (released 2019-01-23) + includes + a + security + fix to the crypto/elliptic package. + See the + Go 1.10.8 milestone + on our issue tracker for details. +

    +

    go1.9 (released 2017-08-24)

    +

    + Go 1.9 is a major release of Go. + Read the Go 1.9 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.9.1 + (released 2017-10-04) + includes + two + security + fixes. + See the + Go 1.9.1 milestone + on our issue tracker for details. +

    +

    + go1.9.2 + (released 2017-10-25) + includes + fixes to the compiler, linker, runtime, documentation, go command, and the crypto/x509, database/sql, log, and net/smtp packages. + It includes a fix to a bug introduced in Go 1.9.1 that broke go get + of non-Git repositories under certain conditions. + See the + Go 1.9.2 milestone + on our issue tracker for details. +

    +

    + go1.9.3 + (released 2018-01-22) + includes + fixes to the compiler, runtime, and the database/sql, math/big, net/http, and net/url packages. + See the + Go 1.9.3 milestone + on our issue tracker for details. +

    +

    + go1.9.4 + (released 2018-02-07) + includes + a + security + fix to "go get". + See the + Go 1.9.4 milestone + on our issue tracker for details. +

    +

    + go1.9.5 + (released 2018-03-28) + includes + fixes to the compiler, go command, and the net/http/pprof package. + See the + Go 1.9.5 milestone + on our issue tracker for details. +

    +

    + go1.9.6 + (released 2018-05-01) + includes + fixes to the compiler and go command. + See the + Go 1.9.6 milestone + on our issue tracker for details. +

    +

    + go1.9.7 + (released 2018-06-05) + includes + fixes to the go command, and the crypto/x509 and strings packages. + In particular, it adds + minimal support to the go command for the vgo transition. + See the + Go 1.9.7 milestone + on our issue tracker for details. +

    +

    go1.8 (released 2017-02-16)

    +

    + Go 1.8 is a major release of Go. + Read the Go 1.8 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.8.1 (released 2017-04-07) includes fixes to the compiler, linker, runtime, + documentation, go command and the crypto/tls, + encoding/xml, image/png, net, + net/http, reflect, text/template, + and time packages. + See the Go + 1.8.1 milestone on our issue tracker for details. +

    +

    + go1.8.2 (released 2017-05-23) includes a security fix to the + crypto/elliptic package. + See the Go + 1.8.2 milestone on our issue tracker for details. +

    +

    + go1.8.3 (released 2017-05-24) includes fixes to the compiler, runtime, + documentation, and the database/sql package. + See the Go + 1.8.3 milestone on our issue tracker for details. +

    +

    + go1.8.4 (released 2017-10-04) includes two security fixes. + It contains the same fixes as Go 1.9.1 and was released at the same time. + See the Go + 1.8.4 milestone on our issue tracker for details. +

    +

    + go1.8.5 (released 2017-10-25) includes fixes to the compiler, linker, runtime, + documentation, go command, + and the crypto/x509 and net/smtp packages. + It includes a fix to a bug introduced in Go 1.8.4 that broke go get + of non-Git repositories under certain conditions. + See the Go + 1.8.5 milestone on our issue tracker for details. +

    +

    + go1.8.6 (released 2018-01-22) includes the same fix in math/big + as Go 1.9.3 and was released at the same time. + See the Go + 1.8.6 milestone on our issue tracker for details. +

    +

    + go1.8.7 (released 2018-02-07) includes a security fix to "go get". + It contains the same fix as Go 1.9.4 and was released at the same time. + See the Go + 1.8.7 milestone on our issue tracker for details. +

    +

    go1.7 (released 2016-08-15)

    +

    + Go 1.7 is a major release of Go. + Read the Go 1.7 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.7.1 (released 2016-09-07) includes fixes to the compiler, runtime, + documentation, and the compress/flate, hash/crc32, + io, net, net/http, + path/filepath, reflect, and syscall + packages. + See the Go + 1.7.1 milestone on our issue tracker for details. +

    +

    + go1.7.2 should not be used. It was tagged but not fully released. + The release was deferred due to a last minute bug report. + Use go1.7.3 instead, and refer to the summary of changes below. +

    +

    + go1.7.3 (released 2016-10-19) includes fixes to the compiler, runtime, + and the crypto/cipher, crypto/tls, + net/http, and strings packages. + See the Go + 1.7.3 milestone on our issue tracker for details. +

    +

    + go1.7.4 (released 2016-12-01) includes two security fixes. + See the Go + 1.7.4 milestone on our issue tracker for details. +

    +

    + go1.7.5 (released 2017-01-26) includes fixes to the compiler, runtime, + and the crypto/x509 and time packages. + See the Go + 1.7.5 milestone on our issue tracker for details. +

    +

    + go1.7.6 (released 2017-05-23) includes the same security fix as Go 1.8.2 and + was released at the same time. + See the Go + 1.8.2 milestone on our issue tracker for details. +

    +

    go1.6 (released 2016-02-17)

    +

    + Go 1.6 is a major release of Go. + Read the Go 1.6 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.6.1 (released 2016-04-12) includes two security fixes. + See the Go + 1.6.1 milestone on our issue tracker for details. +

    +

    + go1.6.2 (released 2016-04-20) includes fixes to the compiler, runtime, tools, + documentation, and the mime/multipart, net/http, and + sort packages. + See the Go + 1.6.2 milestone on our issue tracker for details. +

    +

    + go1.6.3 (released 2016-07-17) includes security fixes to the + net/http/cgi package and net/http package when used in + a CGI environment. + See the Go + 1.6.3 milestone on our issue tracker for details. +

    +

    + go1.6.4 (released 2016-12-01) includes two security fixes. + It contains the same fixes as Go 1.7.4 and was released at the same time. + See the Go + 1.7.4 milestone on our issue tracker for details. +

    +

    go1.5 (released 2015-08-19)

    +

    + Go 1.5 is a major release of Go. + Read the Go 1.5 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.5.1 (released 2015-09-08) includes bug fixes to the compiler, assembler, and + the fmt, net/textproto, net/http, and + runtime packages. + See the Go + 1.5.1 milestone on our issue tracker for details. +

    +

    + go1.5.2 (released 2015-12-02) includes bug fixes to the compiler, linker, and + the mime/multipart, net, and runtime + packages. + See the Go + 1.5.2 milestone on our issue tracker for details. +

    +

    + go1.5.3 (released 2016-01-13) includes a security fix to the math/big package + affecting the crypto/tls package. + See the release announcement for details. +

    +

    + go1.5.4 (released 2016-04-12) includes two security fixes. + It contains the same fixes as Go 1.6.1 and was released at the same time. + See the Go + 1.6.1 milestone on our issue tracker for details. +

    +

    go1.4 (released 2014-12-10)

    +

    + Go 1.4 is a major release of Go. + Read the Go 1.4 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.4.1 (released 2015-01-15) includes bug fixes to the linker and the log, syscall, and runtime packages. + See the Go 1.4.1 milestone on our issue tracker for details. +

    +

    + go1.4.2 (released 2015-02-17) includes bug fixes to the go command, the compiler and linker, and the runtime, syscall, reflect, and math/big packages. + See the Go 1.4.2 milestone on our issue tracker for details. +

    +

    + go1.4.3 (released 2015-09-22) includes security fixes to the net/http package and bug fixes to the runtime package. + See the Go 1.4.3 milestone on our issue tracker for details. +

    +

    go1.3 (released 2014-06-18)

    +

    + Go 1.3 is a major release of Go. + Read the Go 1.3 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.3.1 (released 2014-08-13) includes bug fixes to the compiler and the runtime, net, and crypto/rsa packages. + See the change history for details. +

    +

    + go1.3.2 (released 2014-09-25) includes bug fixes to cgo and the crypto/tls packages. + See the change history for details. +

    +

    + go1.3.3 (released 2014-09-30) includes further bug fixes to cgo, the runtime package, and the nacl port. + See the change history for details. +

    +

    go1.2 (released 2013-12-01)

    +

    + Go 1.2 is a major release of Go. + Read the Go 1.2 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.2.1 (released 2014-03-02) includes bug fixes to the runtime, net, and database/sql packages. + See the change history for details. +

    +

    + go1.2.2 (released 2014-05-05) includes a + security fix + that affects the tour binary included in the binary distributions (thanks to Guillaume T). +

    +

    go1.1 (released 2013-05-13)

    +

    + Go 1.1 is a major release of Go. + Read the Go 1.1 Release Notes for more information. +

    +

    Minor revisions

    +

    + go1.1.1 (released 2013-06-13) includes several compiler and runtime bug fixes. + See the change history for details. +

    +

    + go1.1.2 (released 2013-08-13) includes fixes to the gc compiler + and cgo, and the bufio, runtime, + syscall, and time packages. + See the change history for details. + If you use package syscall's Getrlimit and Setrlimit + functions under Linux on the ARM or 386 architectures, please note change + 11803043 + that fixes issue 5949. +

    +

    go1 (released 2012-03-28)

    +

    + Go 1 is a major release of Go that will be stable in the long term. + Read the Go 1 Release Notes for more information. +

    +

    + It is intended that programs written for Go 1 will continue to compile and run + correctly, unchanged, under future versions of Go 1. + Read the Go 1 compatibility document for more + about the future of Go 1. +

    +

    + The go1 release corresponds to + weekly.2012-03-27. +

    +

    Minor revisions

    +

    + go1.0.1 (released 2012-04-25) was issued to + fix an + escape analysis bug + that can lead to memory corruption. + It also includes several minor code and documentation fixes. +

    +

    + go1.0.2 (released 2012-06-13) was issued to fix two bugs in the implementation + of maps using struct or array keys: + issue 3695 and + issue 3573. + It also includes many minor code and documentation fixes. +

    +

    + go1.0.3 (released 2012-09-21) includes minor code and documentation fixes. +

    +

    + See the go1 release branch history for the complete list of changes. +

    diff --git a/cmd/golangorg/testdata/web.txt b/cmd/golangorg/testdata/web.txt new file mode 100644 index 00000000..ca48661b --- /dev/null +++ b/cmd/golangorg/testdata/web.txt @@ -0,0 +1,99 @@ +GET / +body contains Go is an open source programming language +body contains Binary distributions available for + +GET /conduct +body contains Project Stewards + +GET /doc/asm +body ~ Quick Guide.*Assembler + +GET /doc/gdb +body contains Debugging Go Code + +GET /doc/debugging_with_gdb.html +redirect == /doc/gdb + +GET /ref/spec +body contains Go Programming Language Specification + +GET /doc/go_spec +redirect == /ref/spec + +GET /doc/go_spec.html +redirect == /ref/spec + +GET /doc/go_spec.md +redirect == /ref/spec + +GET /ref/mem +body contains Memory Model + +GET /doc/go_mem.html +redirect == /ref/mem + +GET /doc/go_mem.md +redirect == /ref/mem + +GET /doc/help.html +redirect == /help + +GET /help/ +redirect == /help + +GET /help +body contains Get help + +GET /pkg/fmt/ +body contains Package fmt implements formatted I/O + +GET /src/fmt/ +body contains scan_test.go + +GET /src/fmt/print.go +body contains // Println formats using + +GET /pkg +redirect == /pkg/ + +GET /pkg/ +body contains Standard library +body contains Package fmt implements formatted I/O +body !contains internal/syscall +body !contains cmd/gc + +GET /pkg/?m=all +body contains Standard library +body contains Package fmt implements formatted I/O +body contains internal/syscall/?m=all +body !contains cmd/gc + +GET /pkg/strings/ +body contains href="/src/strings/strings.go" + +GET /cmd/compile/internal/amd64/ +body contains href="/src/cmd/compile/internal/amd64/ssa.go" + +GET /pkg/math/bits/ +body contains Added in Go 1.9 + +GET /pkg/net/ +body contains // IPv6 scoped addressing zone; added in Go 1.1 + +GET /pkg/net/http/httptrace/ +body ~ Got1xxResponse.*// Go 1\.11 +body ~ GotFirstResponseByte func\(\)\s*$ + +GET /pkg/database/sql/ +body contains The number of connections currently in use; added in Go 1.11 +body contains The number of idle connections; added in Go 1.11 + +GET /project +body contains
  • Go 1.14 (February 2020)
  • +body contains
  • Go 1.1 (May 2013)
  • + +GET /doc/go1.16.html +redirect == /doc/go1.16 + +GET /doc/go1.16 +body contains Go 1.16 diff --git a/cmd/golangorg/testdata/x.txt b/cmd/golangorg/testdata/x.txt new file mode 100644 index 00000000..47049268 --- /dev/null +++ b/cmd/golangorg/testdata/x.txt @@ -0,0 +1,25 @@ +GET /x/net +code == 200 +body contains +body contains http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net"> + +GET /x/net/suffix +code == 200 +body contains +body contains http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net/suffix"> + +GET /x/pkgsite +code == 200 +body contains +body contains Redirecting to documentation... +body contains http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/pkgsite"> + +GET /x/notexist +code == 404 + +GET /x/ +code == 307 +header location == https://pkg.go.dev/search?q=golang.org/x + +GET /x/In%20Valid,X +code == 404 diff --git a/cmd/golangorg/x_test.go b/cmd/golangorg/x_test.go index 19688076..aedc2dbb 100644 --- a/cmd/golangorg/x_test.go +++ b/cmd/golangorg/x_test.go @@ -8,98 +8,12 @@ package main import ( - "net/http/httptest" - "strings" + "net/http" "testing" + + "golang.org/x/website/internal/webtest" ) func TestXHandler(t *testing.T) { - type check func(t *testing.T, rec *httptest.ResponseRecorder) - status := func(v int) check { - return func(t *testing.T, rec *httptest.ResponseRecorder) { - t.Helper() - if rec.Code != v { - t.Errorf("response status = %v; want %v", rec.Code, v) - } - } - } - substr := func(s string) check { - return func(t *testing.T, rec *httptest.ResponseRecorder) { - t.Helper() - if !strings.Contains(rec.Body.String(), s) { - t.Errorf("missing expected substring %q in value: %#q", s, rec.Body) - } - } - } - hasHeader := func(k, v string) check { - return func(t *testing.T, rec *httptest.ResponseRecorder) { - t.Helper() - if got := rec.HeaderMap.Get(k); got != v { - t.Errorf("header[%q] = %q; want %q", k, got, v) - } - } - } - - tests := []struct { - name string - path string - checks []check - }{ - { - name: "net", - path: "/x/net", - checks: []check{ - status(200), - substr(``), - substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net">`), - }, - }, - { - name: "net-suffix", - path: "/x/net/suffix", - checks: []check{ - status(200), - substr(``), - substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net/suffix">`), - }, - }, - { - name: "pkgsite", - path: "/x/pkgsite", - checks: []check{ - status(200), - substr(``), - substr(`Redirecting to documentation...`), - substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/pkgsite">`), - }, - }, - { - name: "notexist", - path: "/x/notexist", - checks: []check{status(404)}, - }, - { - name: "empty", - path: "/x/", - checks: []check{ - status(307), - hasHeader("Location", "https://pkg.go.dev/search?q=golang.org/x"), - }, - }, - { - name: "invalid", - path: "/x/In%20Valid,X", - checks: []check{status(404)}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - req := httptest.NewRequest("GET", tt.path, nil) - rec := httptest.NewRecorder() - xHandler(rec, req) - for _, check := range tt.checks { - check(t, rec) - } - }) - } + webtest.TestHandler(t, "testdata/x.txt", http.HandlerFunc(xHandler)) } -- cgit v1.3