cmd/golangorg: deduplicate testdata/live.txt and testdata/web.txt
These are duplicates for no particularly good reason anymore.
Move the general tests into testdata/web.txt, leaving in live.txt
only the tests that cannot work except in production.
Change-Id: Ia8b4271a9cce78814ac57c7b4a462383e77ee3d5
Reviewed-on: https://go-review.googlesource.com/c/website/+/328010
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/golangorg/godoc_test.go b/cmd/golangorg/godoc_test.go
index 79d0201..829331a 100644
--- a/cmd/golangorg/godoc_test.go
+++ b/cmd/golangorg/godoc_test.go
@@ -100,4 +100,5 @@
waitForServerReady(t, addr)
webtest.TestServer(t, "testdata/web.txt", addr)
+ webtest.TestServer(t, "testdata/release.txt", addr)
}
diff --git a/cmd/golangorg/regtest_test.go b/cmd/golangorg/regtest_test.go
index f89b05c..dc0416b 100644
--- a/cmd/golangorg/regtest_test.go
+++ b/cmd/golangorg/regtest_test.go
@@ -22,5 +22,5 @@
t.Skip("regtest.host flag missing.")
}
- webtest.TestServer(t, "testdata/live.txt", *host)
+ webtest.TestServer(t, "testdata/*.txt", *host)
}
diff --git a/cmd/golangorg/release_test.go b/cmd/golangorg/release_test.go
deleted file mode 100644
index c74526f..0000000
--- a/cmd/golangorg/release_test.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2020 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 main
-
-import (
- "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.
-//
-// At this time, the test is very strict and checks that all releases
-// from Go 1 to Go 1.14.2 are included with exact HTML content.
-// It can be relaxed whenever the presentation of the release history
-// page needs to be changed.
-func TestReleaseHistory(t *testing.T) {
- fsys := website.Content
- site, err := web.NewSite(fsys)
- if err != nil {
- t.Fatal(err)
- }
- mux := registerHandlers(fsys, site)
-
- webtest.TestHandler(t, "testdata/release.txt", mux)
-}
diff --git a/cmd/golangorg/testdata/live.txt b/cmd/golangorg/testdata/live.txt
index 02c0e4e..92c5a29 100644
--- a/cmd/golangorg/testdata/live.txt
+++ b/cmd/golangorg/testdata/live.txt
@@ -1,36 +1,5 @@
-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-
+# Tests that can only run against the live server,
+# because they depend on production resources.
GET /dl/
body contains href="/dl/go1.11.windows-amd64.msi"
@@ -65,17 +34,3 @@
postbody
package main
body !contains UA-
-
-GET /x/net
-code == 200
-body contains <meta name="go-import" content="golang.org/x/net git https://go.googlesource.com/net">
-body !contains UA-
-
-GET /project
-body contains <li><a href="/doc/go1.14">Go 1.14</a> <small>(February 2020)</small></li>
-
-GET /project/
-redirect == /project
-
-GET /project/notexist
-code == 404
diff --git a/cmd/golangorg/testdata/web.txt b/cmd/golangorg/testdata/web.txt
index ca48661..e3e2c39 100644
--- a/cmd/golangorg/testdata/web.txt
+++ b/cmd/golangorg/testdata/web.txt
@@ -2,20 +2,44 @@
body contains Go is an open source programming language
body contains Binary distributions available for
+GET /change/75944e2e3a63
+code == 302
+redirect contains bdb10cf
+body contains bdb10cf
+body !contains UA-
+
+GET /cmd/compile/internal/amd64/
+body contains href="/src/cmd/compile/internal/amd64/ssa.go"
+
GET /conduct
body contains Project Stewards
+GET /doc/
+body contains an introduction to using modules in a simple project
+
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/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 /doc/gdb
+body contains Debugging Go Code
+
+GET /doc/go1.16.html
+redirect == /doc/go1.16
+
+GET /doc/go1.16
+body contains Go 1.16
GET /doc/go_spec
redirect == /ref/spec
@@ -26,9 +50,6 @@
GET /doc/go_spec.md
redirect == /ref/spec
-GET /ref/mem
-body contains Memory Model
-
GET /doc/go_mem.html
redirect == /ref/mem
@@ -68,8 +89,12 @@
body contains internal/syscall/?m=all
body !contains cmd/gc
-GET /pkg/strings/
-body contains href="/src/strings/strings.go"
+GET /pkg/bufio/
+body contains href="/pkg/io/#Writer
+
+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 /cmd/compile/internal/amd64/
body contains href="/src/cmd/compile/internal/amd64/ssa.go"
@@ -80,20 +105,40 @@
GET /pkg/net/
body contains // IPv6 scoped addressing zone; added in Go 1.1
+GET /pkg/net/http/
+body contains title="Added in Go 1.11"
+
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 /pkg/os/
+body contains func Open
+
+GET /pkg/strings/
+body contains href="/src/strings/strings.go"
GET /project
body contains <li><a href="/doc/go1.14">Go 1.14</a> <small>(February 2020)</small></li>
body contains <li><a href="/doc/go1.1">Go 1.1</a> <small>(May 2013)</small></li>
-GET /doc/go1.16.html
-redirect == /doc/go1.16
+GET /project/
+redirect == /project
-GET /doc/go1.16
-body contains Go 1.16
+GET /project/notexist
+code == 404
+
+GET /ref/mem
+body contains Memory Model
+
+GET /ref/spec
+body contains Go Programming Language Specification
+
+GET /robots.txt
+body contains Disallow: /search
+body !contains UA-
+
+GET /x/net
+code == 200
+body contains <meta name="go-import" content="golang.org/x/net git https://go.googlesource.com/net">
+body !contains UA-
diff --git a/internal/webtest/webtest.go b/internal/webtest/webtest.go
index 8fe9b33..27765f8 100644
--- a/internal/webtest/webtest.go
+++ b/internal/webtest/webtest.go
@@ -24,6 +24,7 @@
// Scripts
//
// A script is a text file containing a sequence of cases, separated by blank lines.
+// Lines beginning with # characters are ignored as comments.
// A case is a sequence of lines describing a request, along with checks to be
// applied to the response. For example, here is a trivial script:
//