aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2021-12-13 21:19:45 +0000
committerJamal Carvalho <jamalcarvalho@google.com>2021-12-16 14:37:07 +0000
commit4e7a786f450dd54fbbc29fa6de10c5f7a97da58c (patch)
tree8319b2f18f447f206f718ca9312a0853fa2b4434 /cmd
parent0c791db1802ac28166aaec369b0abb241405c8fc (diff)
downloadgo-x-website-4e7a786f450dd54fbbc29fa6de10c5f7a97da58c.tar.xz
internal/screentest: add package to compare screenshots web pages
As we clean up page styles post golang.org and go.dev merge, and begin to implement the dark theme, we can use screenshot testing to check that code changes don't result in unintended style or html content changes. Change-Id: Ia65f98f133df0f4a9fa3f382fd30c2455d65d73d Reviewed-on: https://go-review.googlesource.com/c/website/+/371435 Run-TryBot: Jamal Carvalho <jamal@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Jonathan Amsterdam <jba@google.com> Trust: Jamal Carvalho <jamalcarvalho@google.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/screentest/main.go23
-rw-r--r--cmd/screentest/testdata/godev.txt32
2 files changed, 55 insertions, 0 deletions
diff --git a/cmd/screentest/main.go b/cmd/screentest/main.go
new file mode 100644
index 00000000..a60c1033
--- /dev/null
+++ b/cmd/screentest/main.go
@@ -0,0 +1,23 @@
+// Copyright 2021 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.
+
+// Command screentest runs the visual diff check for the set of scripts
+// provided by the flag -testdata.
+package main
+
+import (
+ "flag"
+ "log"
+
+ "golang.org/x/website/internal/screentest"
+)
+
+var testdata = flag.String("testdata", "cmd/screentest/testdata/*.txt", "directory to look for testdata")
+
+func main() {
+ flag.Parse()
+ if err := screentest.CheckHandler(*testdata); err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/cmd/screentest/testdata/godev.txt b/cmd/screentest/testdata/godev.txt
new file mode 100644
index 00000000..f92ab571
--- /dev/null
+++ b/cmd/screentest/testdata/godev.txt
@@ -0,0 +1,32 @@
+windowsize 1536x960
+compare https://go.dev http://localhost:6060/go.dev
+
+test homepage
+pathname /
+capture fullscreen
+capture fullscreen 540x1080
+
+test why go
+pathname /solutions/
+capture fullscreen
+capture fullscreen 540x1080
+
+test getting started
+pathname /learn/
+capture fullscreen
+capture fullscreen 540x1080
+
+test docs
+pathname /doc/
+capture fullscreen
+capture fullscreen 540x1080
+
+test playground
+pathname /play/
+capture fullscreen
+capture fullscreen 540x1080
+
+test blog
+pathname /blog/
+capture fullscreen
+capture fullscreen 540x1080