diff options
| author | Jamal Carvalho <jamal@golang.org> | 2021-12-22 18:33:35 +0000 |
|---|---|---|
| committer | Jamal Carvalho <jamalcarvalho@google.com> | 2022-01-04 16:25:02 +0000 |
| commit | afa30cd2ef98dddb594ced3fb40a7c2f2864a651 (patch) | |
| tree | 3685e2e9a53d07f77d0b399bf75ba1f7dd287ea0 /cmd | |
| parent | f07bd53eacd2d2fce298fb0ea31be6c21f477159 (diff) | |
| download | go-x-website-afa30cd2ef98dddb594ced3fb40a7c2f2864a651.tar.xz | |
cmd/screentest: use default testdata when run with go command
Change-Id: I9e3a1a71ec62cfbb171f55e765b5f58d3ddba4e5
Reviewed-on: https://go-review.googlesource.com/c/website/+/373717
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Trust: Jamal Carvalho <jamalcarvalho@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/screentest/main.go | 10 | ||||
| -rw-r--r-- | cmd/screentest/testdata/godev.txt | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/cmd/screentest/main.go b/cmd/screentest/main.go index 04763147..a628459e 100644 --- a/cmd/screentest/main.go +++ b/cmd/screentest/main.go @@ -10,6 +10,7 @@ import ( "fmt" "log" "os" + "path/filepath" "strings" "golang.org/x/website/internal/screentest" @@ -27,10 +28,15 @@ func main() { } flag.Parse() args := flag.Args() - if len(args) != 1 { + // Require testdata glob when invoked as an installed command. + if len(args) != 1 && os.Args[0] == "screentest" { flag.Usage() os.Exit(1) } + glob := filepath.Join("cmd", "screentest", "testdata", "*") + if len(args) == 1 { + glob = args[0] + } parsedVars := make(map[string]string) if *vars != "" { for _, pair := range strings.Split(*vars, ",") { @@ -41,7 +47,7 @@ func main() { parsedVars[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) } } - if err := screentest.CheckHandler(args[0], *update, parsedVars); err != nil { + if err := screentest.CheckHandler(glob, *update, parsedVars); err != nil { log.Fatal(err) } } diff --git a/cmd/screentest/testdata/godev.txt b/cmd/screentest/testdata/godev.txt index a19ea05e..26451b34 100644 --- a/cmd/screentest/testdata/godev.txt +++ b/cmd/screentest/testdata/godev.txt @@ -1,5 +1,5 @@ windowsize 1536x960 -compare https://go.dev http://localhost:6060/go.dev +compare https://go.dev::cache http://localhost:6060/go.dev test homepage pathname / |
