[bazel] Make use of test_on_env to spin up server for gms

In order to extract the PNG files produced by our CanvasKit gms,
we need our JS tests to POST them to a server which can write to
disk. The easiest way to do this is to use the test_on_env
rule defined in the Skia Infra repo for exactly this purpose.

This required https://skia-review.googlesource.com/c/buildbot/+/510717
to be able to configure the binary correctly and
https://skia-review.googlesource.com/c/buildbot/+/511862, for nicer
debugging so the skia-infra dep was updated via the following commands:
$ go get go.skia.org/infra@d8a552a29e
$ go mod download
$ make -C infra/bots train
$ make -C bazel gazelle_update_repo
This caused many automated changes to infra/bots/tasks.json

The flow is:
1. User types bazelisk test :hello_world_test_with_env
2. The test_on_env rule starts gold_test_env and waits
   for the file defined in $ENV_READY_FILE to be created.
3. gold_test_env starts a web server on a random port. It
   writes this port number to $ENV_DIR/port. Then, it
   creates $ENV_READY_FILE to signal ready.
4. test_on_env sees the ready file and then starts the
   karma_test rule. (Reminder: this is a bash script
   which starts karma using the Bazel-bundled chromium).
5. The karma_test rule runs the karma.bazel.js file (which
   has been injected with some JS code to fill in Bazel
   paths and settings) using Bazel-bundled node. This reads
   in the port file and sets up a Karma proxy to redirect
   /gold_rpc/report to http://localhost:PORT/report
6. The JS tests run via Karma (and do assertions via Jasmine).
   Some tests, the gms, make POST requests to the proxy.
7. gold_test_env gets these POST requests writes the images
   to a special Bazel folder on disk as defined by
   $TEST_UNDECLARED_OUTPUTS_DIR.
8. test_on_env identifies that the tests finish (because the
   karma_test script returns 0). It sends SIGINT to gold_test_env.
9. gold_test_env stops the webserver. The special Bazel folder
   will zip up anything inside it and make it available for
   future rules (e.g. a rule that will upload to Gold via goldctl).

Suggested Review Order:
 - bazel/karma_test.bzl to see the test_on_env rule bundled into
   the karma_test macro. I chose to put it there because it might
   be confusing to have to define both a karma_test and test_on_env
   rule in the same package but not be able to call one because it
   will fail to talk to the server.
 - gold_test_env.go to see how the appropriate files are written
   to signal the environment is ready and the handlers are set up.
 - karma.bazel.js to see how we make our own proxy given the
   port from the env binary. The fact that we could not create
   our own proxy with the existing karma_test rule was why the
   chain ending in https://skia-review.googlesource.com/c/skia/+/508797
   had to be abandoned.
 - tests/*.js to see how the environment is probed via /healthz
   and then used to make POST requests with data.
 - Everything else.

Change-Id: I32a90def41796ca94cf187d640cfff8e262f85f6
BUG: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/510737
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
This commit is contained in:
Kevin Lubick 2022-02-28 08:56:47 -05:00
parent f988cba8a7
commit acab911351
22 changed files with 4634 additions and 4204 deletions

View File

@ -7,7 +7,8 @@ generate:
modules/skshaper modules/svg modules/skresources modules/skparagraph modules/skunicode \
modules/skottie modules/skresources modules/sksg experimental/ffmpeg \
modules/particles \
experimental/bazel_test experimental/graphite example
experimental/bazel_test experimental/graphite example \
modules/canvaskit/go
# This target should be run after the go.mod file is updated (e.g. version rolls or new updates)
gazelle_update_repo:

View File

@ -1,10 +1,14 @@
"""This module defines rules for running JS tests in a browser."""
load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "node_modules_aspect")
# https://github.com/bazelbuild/rules_webtesting/blob/master/web/web.bzl
load("@io_bazel_rules_webtesting//web:web.bzl", "web_test")
load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "node_modules_aspect")
def karma_test(name, config_file, srcs, static_files = None, **kwargs):
# https://github.com/google/skia-buildbot/blob/main/bazel/test_on_env/test_on_env.bzl
load("@org_skia_go_infra//bazel/test_on_env:test_on_env.bzl", "test_on_env")
def karma_test(name, config_file, srcs, static_files = None, env = None, **kwargs):
"""Tests the given JS files using Karma and a browser provided by Bazel (Chromium)
This rule injects some JS code into the karma config file and produces both that modified
@ -34,6 +38,10 @@ def karma_test(name, config_file, srcs, static_files = None, **kwargs):
Examples:
- `/static/skia/modules/canvaskit/tests/assets/color_wheel.gif`
- `/static/skia/modules/canvaskit/canvaskit_wasm/canvaskit.wasm`
env: An optional label to a binary. If set, the test will be wrapped in a test_on_env rule,
and this binary will be used as the "env" part of test_on_env. It will be started before
the tests run and be running in parallel to them. See the test_on_env.bzl in the
Skia Infra repo for more.
**kwargs: Additional arguments are passed to @io_bazel_rules_webtesting/web_test.
"""
if len(srcs) == 0:
@ -41,9 +49,9 @@ def karma_test(name, config_file, srcs, static_files = None, **kwargs):
if not static_files:
static_files = []
wrapped_test_name = name + "_karma_test"
karma_test_name = name + "_karma_test"
_karma_test(
name = wrapped_test_name,
name = karma_test_name,
srcs = srcs,
deps = [
"@npm//karma-chrome-launcher",
@ -54,18 +62,36 @@ def karma_test(name, config_file, srcs, static_files = None, **kwargs):
config_file = config_file,
static_files = static_files,
visibility = ["//visibility:private"],
tags = ["manual"],
)
# See the following link for the options.
# https://github.com/bazelbuild/rules_webtesting/blob/e9cf17123068b1123c68219edf9b274bf057b9cc/web/internal/web_test.bzl#L164
# TODO(kjlubick) consider using web_test_suite to test on Firefox as well.
web_test(
name = name,
launcher = ":" + wrapped_test_name,
browser = "@io_bazel_rules_webtesting//browsers:chromium-local",
test = wrapped_test_name,
**kwargs
)
if not env:
web_test(
name = name,
launcher = ":" + karma_test_name,
browser = "@io_bazel_rules_webtesting//browsers:chromium-local",
test = karma_test_name,
**kwargs
)
else:
web_test_name = name + "_web_test"
web_test(
name = web_test_name,
launcher = ":" + karma_test_name,
browser = "@io_bazel_rules_webtesting//browsers:chromium-local",
test = karma_test_name,
visibility = ["//visibility:private"],
**kwargs
)
test_on_env(
name = name,
env = env,
test = ":" + web_test_name,
test_on_env_binary = "@org_skia_go_infra//bazel/test_on_env:test_on_env",
)
# This JS code is injected into the the provided karma configuration file. It contains
# Bazel-specific logic that could be re-used across different configuration files.

View File

@ -587,7 +587,6 @@ generated_cc_atom(
deps = [
":CommandBuffer_hdr",
":GraphicsPipelineDesc_hdr",
":ResourceCache_hdr",
":ResourceTypes_hdr",
"//include/core:SkSize_hdr",
"//include/core:SkTileMode_hdr",
@ -608,6 +607,7 @@ generated_cc_atom(
":GlobalCache_hdr",
":Gpu_hdr",
":GraphicsPipeline_hdr",
":ResourceCache_hdr",
":ResourceProvider_hdr",
":Sampler_hdr",
":Texture_hdr",
@ -812,8 +812,9 @@ generated_cc_atom(
hdrs = ["Resource.h"],
visibility = ["//:__subpackages__"],
deps = [
":GraphiteResourceKey_hdr",
":ResourceTypes_hdr",
"//include/core:SkTypes_hdr",
"//include/private:SkMutex_hdr",
],
)
@ -821,7 +822,10 @@ generated_cc_atom(
name = "Resource_src",
srcs = ["Resource.cpp"],
visibility = ["//:__subpackages__"],
deps = [":Resource_hdr"],
deps = [
":ResourceCache_hdr",
":Resource_hdr",
],
)
generated_cc_atom(
@ -901,10 +905,13 @@ generated_cc_atom(
hdrs = ["ResourceCache.h"],
visibility = ["//:__subpackages__"],
deps = [
":Resource_hdr",
":ResourceTypes_hdr",
"//include/core:SkRefCnt_hdr",
"//include/private:SkMutex_hdr",
"//include/private:SkTArray_hdr",
"//include/private:SkTHash_hdr",
"//src/core:SkTDPQueue_hdr",
"//src/core:SkTMultiMap_hdr",
],
)
@ -913,9 +920,11 @@ generated_cc_atom(
srcs = ["ResourceCache.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":GraphiteResourceKey_hdr",
":ResourceCache_hdr",
":Resource_hdr",
"//include/private:SingleOwner_hdr",
"//src/core:SkTMultiMap_hdr",
],
)

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/prometheus/common v0.15.0 // indirect
github.com/stretchr/testify v1.6.1
go.chromium.org/luci v0.0.0-20201121231857-b9ab316d7198 // indirect
go.skia.org/infra v0.0.0-20220110171919-69477ccd2d29
go.skia.org/infra v0.0.0-20220223133516-d8a552a29e02
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58
google.golang.org/api v0.35.0

33
go.sum
View File

@ -396,6 +396,10 @@ github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
@ -472,6 +476,14 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+
github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
github.com/go-openapi/validate v0.19.8 h1:YFzsdWIDfVuLvIOF+ZmKjVg1MbPJ1QgY9PihMwei1ys=
github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/go-python/gpython v0.0.3 h1:QNFZ0h540Lajx7Pi/os06XzzdYUQG+2sV7IvPo/Mvmg=
github.com/go-python/gpython v0.0.3/go.mod h1:bmk0l57W/7Cs67MMnz4U28SoYyvz5NTMYyJvUqytJhs=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
@ -483,6 +495,12 @@ github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI=
github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4 h1:vF83LI8tAakwEwvWZtrIEx7pOySacl2TOxx6eXk4ePo=
github.com/gocql/gocql v0.0.0-20190301043612-f6df8288f9b4/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0=
github.com/godbus/dbus v4.1.0+incompatible h1:WqqLRTsQic3apZUK9qC5sGNfXthmPXzUZ7nQPrNITa4=
@ -635,6 +653,7 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM=
@ -800,6 +819,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
@ -823,6 +843,7 @@ github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHz
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@ -846,6 +867,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@ -1245,8 +1268,12 @@ github.com/twitchtv/twirp v7.1.0+incompatible h1:3fNSDoSPyq+fTrifIvGue9XM/tptzuh
github.com/twitchtv/twirp v7.1.0+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/unrolled/secure v1.0.8 h1:JaMvKbe4CRt8oyxVXn+xY+6jlqd7pyJNSVkmsBxxQsM=
github.com/unrolled/secure v1.0.8/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
@ -1321,6 +1348,10 @@ go.skia.org/infra v0.0.0-20211221155757-2dce552b7a06 h1:0nA6CcXj6OayS2l7WKWT8xY/
go.skia.org/infra v0.0.0-20211221155757-2dce552b7a06/go.mod h1:F317bWqAb10VqH9f5yC3cZugJ87N0Lvoi5xjM+vmR1g=
go.skia.org/infra v0.0.0-20220110171919-69477ccd2d29 h1:EQFMh6ZPs6RJ7pyDiH3z1JrIEl/BR2YNGqMAdctU7N8=
go.skia.org/infra v0.0.0-20220110171919-69477ccd2d29/go.mod h1:F317bWqAb10VqH9f5yC3cZugJ87N0Lvoi5xjM+vmR1g=
go.skia.org/infra v0.0.0-20220218204246-e55dd748425d h1:kJI4Qi6P70H38eByqCxaM5P1DSyStOYr56zM1sjoitU=
go.skia.org/infra v0.0.0-20220218204246-e55dd748425d/go.mod h1:M2kWv30a9SuDTrCr46O0KQsbhsP7ean3Z93P09X6+QA=
go.skia.org/infra v0.0.0-20220223133516-d8a552a29e02 h1:a9vcNLAkQ84ggJZkrWeHUggxXUPviw2HVmcGGB7L3UY=
go.skia.org/infra v0.0.0-20220223133516-d8a552a29e02/go.mod h1:M2kWv30a9SuDTrCr46O0KQsbhsP7ean3Z93P09X6+QA=
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@ -1897,6 +1928,8 @@ modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/zappy v1.0.0 h1:dPVaP+3ueIUv4guk8PuZ2wiUGcJ1WUVvIheeSSTD0yk=
modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=

View File

@ -4,8 +4,8 @@ def go_repositories():
go_repository(
name = "co_honnef_go_tools",
importpath = "honnef.co/go/tools",
sum = "h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=",
version = "v0.0.1-2020.1.6",
sum = "h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=",
version = "v0.0.1-2020.1.4",
)
go_repository(
name = "com_github_99designs_goodies",
@ -256,8 +256,8 @@ def go_repositories():
go_repository(
name = "com_github_bazelbuild_rules_go",
importpath = "github.com/bazelbuild/rules_go",
sum = "h1:mb2SfWfQcOkIGTEf8QdRna9nF6nnjlyv/qeXvPVkleE=",
version = "v0.25.0",
sum = "h1:wzbawlkLtl2ze9w/312NHZ84c7kpUCtlkD8HgFY27sw=",
version = "v0.0.0-20190719190356-6dae44dc5cab",
)
go_repository(
name = "com_github_beorn7_perks",
@ -700,8 +700,8 @@ def go_repositories():
go_repository(
name = "com_github_dustin_go_humanize",
importpath = "github.com/dustin/go-humanize",
sum = "h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=",
version = "v1.0.0",
sum = "h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs=",
version = "v0.0.0-20171111073723-bb3d318650d4",
)
go_repository(
name = "com_github_eapache_go_resiliency",
@ -871,6 +871,19 @@ def go_repositories():
sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=",
version = "v1.0.0",
)
go_repository(
name = "com_github_gin_contrib_sse",
importpath = "github.com/gin-contrib/sse",
sum = "h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=",
version = "v0.1.0",
)
go_repository(
name = "com_github_gin_gonic_gin",
importpath = "github.com/gin-gonic/gin",
sum = "h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=",
version = "v1.6.3",
)
go_repository(
name = "com_github_gliderlabs_ssh",
importpath = "github.com/gliderlabs/ssh",
@ -979,6 +992,31 @@ def go_repositories():
sum = "h1:YFzsdWIDfVuLvIOF+ZmKjVg1MbPJ1QgY9PihMwei1ys=",
version = "v0.19.8",
)
go_repository(
name = "com_github_go_playground_assert_v2",
importpath = "github.com/go-playground/assert/v2",
sum = "h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=",
version = "v2.0.1",
)
go_repository(
name = "com_github_go_playground_locales",
importpath = "github.com/go-playground/locales",
sum = "h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=",
version = "v0.13.0",
)
go_repository(
name = "com_github_go_playground_universal_translator",
importpath = "github.com/go-playground/universal-translator",
sum = "h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=",
version = "v0.17.0",
)
go_repository(
name = "com_github_go_playground_validator_v10",
importpath = "github.com/go-playground/validator/v10",
sum = "h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=",
version = "v10.2.0",
)
go_repository(
name = "com_github_go_python_gpython",
importpath = "github.com/go-python/gpython",
@ -1009,6 +1047,25 @@ def go_repositories():
sum = "h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=",
version = "v0.2.3",
)
go_repository(
name = "com_github_gobwas_httphead",
importpath = "github.com/gobwas/httphead",
sum = "h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=",
version = "v0.0.0-20180130184737-2c6c146eadee",
)
go_repository(
name = "com_github_gobwas_pool",
importpath = "github.com/gobwas/pool",
sum = "h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=",
version = "v0.2.0",
)
go_repository(
name = "com_github_gobwas_ws",
importpath = "github.com/gobwas/ws",
sum = "h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=",
version = "v1.0.2",
)
go_repository(
name = "com_github_gocql_gocql",
importpath = "github.com/gocql/gocql",
@ -1708,8 +1765,8 @@ def go_repositories():
go_repository(
name = "com_github_kevinburke_ssh_config",
importpath = "github.com/kevinburke/ssh_config",
sum = "h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=",
version = "v0.0.0-20201106050909-4977a11b4351",
sum = "h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=",
version = "v0.0.0-20190725054713-01f96b0aa0cd",
)
go_repository(
name = "com_github_kisielk_errcheck",
@ -1756,8 +1813,8 @@ def go_repositories():
go_repository(
name = "com_github_kr_pretty",
importpath = "github.com/kr/pretty",
sum = "h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=",
version = "v0.2.1",
sum = "h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=",
version = "v0.2.0",
)
go_repository(
name = "com_github_kr_pty",
@ -1777,6 +1834,13 @@ def go_repositories():
sum = "h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=",
version = "v1.1.0",
)
go_repository(
name = "com_github_leodido_go_urn",
importpath = "github.com/leodido/go-urn",
sum = "h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=",
version = "v1.2.0",
)
go_repository(
name = "com_github_lib_pq",
importpath = "github.com/lib/pq",
@ -1828,8 +1892,8 @@ def go_repositories():
go_repository(
name = "com_github_mailru_easyjson",
importpath = "github.com/mailru/easyjson",
sum = "h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=",
version = "v0.7.6",
sum = "h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=",
version = "v0.7.1",
)
go_repository(
name = "com_github_makenowjust_heredoc",
@ -1888,8 +1952,8 @@ def go_repositories():
go_repository(
name = "com_github_mattn_go_runewidth",
importpath = "github.com/mattn/go-runewidth",
sum = "h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=",
version = "v0.0.9",
sum = "h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=",
version = "v0.0.7",
)
go_repository(
name = "com_github_mattn_go_sqlite3",
@ -1906,8 +1970,8 @@ def go_repositories():
go_repository(
name = "com_github_microsoft_go_winio",
importpath = "github.com/Microsoft/go-winio",
sum = "h1:qkLXKzb1QoVatRyd/YlXZ/Kg0m5K3SPuoD82jjSOaBc=",
version = "v0.4.15",
sum = "h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=",
version = "v0.4.14",
)
go_repository(
name = "com_github_miekg_dns",
@ -2284,8 +2348,8 @@ def go_repositories():
go_repository(
name = "com_github_peterh_liner",
importpath = "github.com/peterh/liner",
sum = "h1:w/UPXyl5GfahFxcTOz2j9wCIHNI+pUPr2laqpojKNCg=",
version = "v1.2.0",
sum = "h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=",
version = "v1.1.0",
)
go_repository(
name = "com_github_phpdave11_gofpdi",
@ -2410,8 +2474,8 @@ def go_repositories():
go_repository(
name = "com_github_rogpeppe_go_internal",
importpath = "github.com/rogpeppe/go-internal",
sum = "h1:Usqs0/lDK/NqTkvrmKSwA/3XkZAs7ZAW/eLeQ2MVBTw=",
version = "v1.5.0",
sum = "h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=",
version = "v1.3.0",
)
go_repository(
name = "com_github_rs_cors",
@ -2704,14 +2768,14 @@ def go_repositories():
go_repository(
name = "com_github_ugorji_go",
importpath = "github.com/ugorji/go",
sum = "h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=",
version = "v1.1.4",
sum = "h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=",
version = "v1.1.7",
)
go_repository(
name = "com_github_ugorji_go_codec",
importpath = "github.com/ugorji/go/codec",
sum = "h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=",
version = "v0.0.0-20181204163529-d75b2dcb6bc8",
sum = "h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=",
version = "v1.1.7",
)
go_repository(
name = "com_github_unrolled_secure",
@ -2788,8 +2852,8 @@ def go_repositories():
go_repository(
name = "com_github_xanzy_ssh_agent",
importpath = "github.com/xanzy/ssh-agent",
sum = "h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=",
version = "v0.3.0",
sum = "h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=",
version = "v0.2.1",
)
go_repository(
name = "com_github_xdg_scram",
@ -3217,6 +3281,13 @@ def go_repositories():
sum = "h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw=",
version = "v0.0.0-20201110183641-67b214c5f920",
)
go_repository(
name = "io_nhooyr_websocket",
importpath = "nhooyr.io/websocket",
sum = "h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=",
version = "v1.8.7",
)
go_repository(
name = "io_opencensus_go",
importpath = "go.opencensus.io",
@ -3244,14 +3315,14 @@ def go_repositories():
go_repository(
name = "io_rsc_sampler",
importpath = "rsc.io/sampler",
sum = "h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8=",
version = "v1.99.99",
sum = "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=",
version = "v1.3.0",
)
go_repository(
name = "net_starlark_go",
importpath = "go.starlark.net",
sum = "h1:JPjLPz44y2N9mkzh2N344kTk1Y4/V4yJAjTrXGmzv8I=",
version = "v0.0.0-20201118183435-e55f603d8c79",
sum = "h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=",
version = "v0.0.0-20200306205701-8dd3e2ee1dd5",
)
go_repository(
name = "org_chromium_go_gae",
@ -3322,8 +3393,8 @@ def go_repositories():
go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
sum = "h1:jqhIzSw5SQNkbu5hOGpgMHhkfXxrbsLJdkIRcX19gCY=",
version = "v0.0.0-20200228211341-fcea875c7e85",
sum = "h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=",
version = "v0.0.0-20200224162631-6cc2880d07d6",
)
go_repository(
name = "org_golang_x_image",
@ -3490,8 +3561,8 @@ def go_repositories():
go_repository(
name = "org_skia_go_infra",
importpath = "go.skia.org/infra",
sum = "h1:EQFMh6ZPs6RJ7pyDiH3z1JrIEl/BR2YNGqMAdctU7N8=",
version = "v0.0.0-20220110171919-69477ccd2d29",
sum = "h1:a9vcNLAkQ84ggJZkrWeHUggxXUPviw2HVmcGGB7L3UY=",
version = "v0.0.0-20220223133516-d8a552a29e02",
)
go_repository(
name = "org_uber_go_atomic",

View File

@ -90,7 +90,6 @@ generated_cc_atom(
":SkTypes_hdr",
"//include/private:SkDeque_hdr",
"//include/private:SkMacros_hdr",
"//include/private:SkTOptional_hdr",
],
)
@ -384,7 +383,6 @@ generated_cc_atom(
":SkImageInfo_hdr",
":SkImage_hdr",
":SkYUVAPixmaps_hdr",
"//include/private:SkTOptional_hdr",
],
)
@ -415,7 +413,6 @@ generated_cc_atom(
":SkShader_hdr",
":SkTileMode_hdr",
"//include/gpu:GrTypes_hdr",
"//include/private:SkTOptional_hdr",
],
)
@ -495,7 +492,6 @@ generated_cc_atom(
":SkBlendMode_hdr",
":SkColor_hdr",
":SkRefCnt_hdr",
"//include/private:SkTOptional_hdr",
"//include/private:SkTo_hdr",
],
)

View File

@ -172,7 +172,6 @@ generated_cc_atom(
"//include/core:SkString_hdr",
"//include/private:SkOnce_hdr",
"//include/private:SkSLSampleUsage_hdr",
"//include/private:SkTOptional_hdr",
],
)

View File

@ -470,12 +470,6 @@ generated_cc_atom(
deps = [":SkTo_hdr"],
)
generated_cc_atom(
name = "SkTOptional_hdr",
hdrs = ["SkTOptional.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "SkTPin_hdr",
hdrs = ["SkTPin.h"],

File diff suppressed because it is too large Load Diff

View File

@ -441,6 +441,8 @@ karma_test(
"tests/hello_world.js",
],
config_file = "karma.bazel.js",
# The tests need the Gold server to be up and running.
env = "//modules/canvaskit/go/gold_test_env:gold_test_env",
static_files = [
":canvaskit_wasm/canvaskit.wasm",
],

View File

@ -160,3 +160,6 @@ bazel_canvaskit_release:
bazel_test_canvaskit:
bazelisk test :hello_world --compilation_mode opt --spawn_strategy=local --test_output=all
echo "test output in //bazel-testlogs/modules/canvaskit/hello_world_test_with_env/test.outputs/"
ls ../../bazel-testlogs/modules/canvaskit/hello_world_test_with_env/test.outputs/

View File

@ -0,0 +1,14 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "gold_test_env_lib",
srcs = ["gold_test_env.go"],
importpath = "go.skia.org/skia/modules/canvaskit/go/gold_test_env",
visibility = ["//visibility:private"],
)
go_binary(
name = "gold_test_env",
embed = [":gold_test_env_lib"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,193 @@
// Copyright 2022 The Chromium 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 (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"os"
"os/signal"
"path"
"path/filepath"
"strconv"
"syscall"
)
const (
envPortFileBaseName = "port"
)
func main() {
envDir, envReadyFile := mustGetEnvironmentVariables()
port, listener := mustGetUnusedNetworkPort()
beginTestManagementLogic(listener)
mustPrepareTestEnvironment(envDir, port)
setupTerminationLogic()
mustSignalTestsCanBegin(envReadyFile)
select {} // Block until the termination handler calls os.Exit
}
// mustGetEnvironmentVariables returns two file paths: a directory that can be used to communicate
// between this binary and the test binaries, and the file that needs to be created when this
// binary has finished setting things up. It panics if it cannot read the values from the
// set environment variables.
func mustGetEnvironmentVariables() (string, string) {
// Read in build paths to the ready and port files.
envDir := os.Getenv("ENV_DIR")
if envDir == "" {
panic("required environment variable ENV_DIR is unset")
}
envReadyFile := os.Getenv("ENV_READY_FILE")
if envReadyFile == "" {
panic("required environment variable ENV_READY_FILE is unset")
}
return envDir, envReadyFile
}
// mustGetUnusedNetworkPort returns a network port chosen by the OS (and assumed to be previously
// unused) and a listener for that port. We choose a non-deterministic port instead of a fixed port
// because multiple tests may be running in parallel.
func mustGetUnusedNetworkPort() (int, net.Listener) {
// Listen on an unused port chosen by the OS.
listener, err := net.Listen("tcp", ":0")
if err != nil {
panic(err)
}
port := listener.Addr().(*net.TCPAddr).Port
fmt.Printf("Environment is ready to go!\nListening on port %d.\n", port)
return port, listener
}
// beginTestManagementLogic sets up the server endpoints which allow the JS gm() tests to exfiltrate
// their PNG images by means of a POST request.
func beginTestManagementLogic(listener net.Listener) {
// The contents of this path go to //bazel-testlogs/path/to/test/test.outputs/ and are combined
// into outputs.zip.
// e.g. ls bazel-testlogs/modules/canvaskit/hello_world_test_with_env/test.outputs/
// test_001
// test_002
// outputs.zip # contains test_001 and test_002
// This environment var is documented in https://bazel.build/reference/test-encyclopedia
outPath := os.Getenv("TEST_UNDECLARED_OUTPUTS_DIR")
if outPath == "" {
panic("output directory was not configured")
}
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
http.HandleFunc("/report", func(w http.ResponseWriter, r *http.Request) {
payload, err := readPayload(r)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
if payload.TestName == "" {
http.Error(w, "Must specify test name", http.StatusBadRequest)
return
}
// Write the data in the POST to the special Bazel output directory
fileContents, err := base64.StdEncoding.DecodeString(payload.Base64Data)
if err != nil {
http.Error(w, "Invalid base64 data "+err.Error(), http.StatusBadRequest)
return
}
fp := filepath.Join(outPath, payload.TestName)
// Two newlines here makes the log stick out more.
fmt.Printf("Writing test data to %s\n\n", fp)
out, err := os.Create(fp)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
panic(err)
}
if _, err := out.Write(fileContents); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
panic(err)
}
// Signal to the test that we have written the data to disk. Tests should be sure to wait
// for this response before signaling they are done to avoid a race condition.
w.WriteHeader(http.StatusCreated)
// We are not worried about an XSS reflection attack here on a local server only up
// when running tests.
if _, err := fmt.Fprintln(w, "Accepted for test "+payload.TestName); err != nil {
panic(err)
}
})
go func() {
serveForever(listener)
}()
}
type testPayload struct {
TestName string `json:"name"`
Base64Data string `json:"b64_data"`
}
// readPayload reads the body of the given request as JSON and parses it into a testPayload struct.
func readPayload(r *http.Request) (testPayload, error) {
var payload testPayload
if r.Body == nil {
return payload, errors.New("no body received")
}
b, err := io.ReadAll(r.Body)
if err != nil {
return payload, err
}
_ = r.Body.Close()
if err := json.Unmarshal(b, &payload); err != nil {
return payload, errors.New("invalid JSON")
}
return payload, nil
}
// serveForever serves the given listener and blocks. If it could not start serving, it will panic.
func serveForever(listener net.Listener) {
// If http.Serve returns, it is an error.
if err := http.Serve(listener, nil); err != nil {
panic(fmt.Sprintf("Finished serving due to error: %s\n", err))
}
}
// mustPrepareTestEnvironment writes any files to the temporary test directory. This is just a file
// that indicates which port the gold tests should make POST requests to. It panics if there are
// any errors.
func mustPrepareTestEnvironment(dirTestsCanRead string, port int) {
envPortFile := path.Join(dirTestsCanRead, envPortFileBaseName)
if err := ioutil.WriteFile(envPortFile, []byte(strconv.Itoa(port)), 0644); err != nil {
panic(err)
}
}
// setupTerminationLogic creates a handler for SIGTERM which is what test_on_env will send the
// environment when the tests complete. There is currently nothing to do other than exit.
func setupTerminationLogic() {
c := make(chan os.Signal, 1)
go func() {
<-c
os.Exit(0)
}()
signal.Notify(c, syscall.SIGTERM)
}
// mustSignalTestsCanBegin creates the agreed upon ENV_READY_FILE which signals the test binary can
// be executed by Bazel. See test_on_env.bzl for more. It panics if the file cannot be created.
func mustSignalTestsCanBegin(envReadyFile string) {
if err := ioutil.WriteFile(envReadyFile, []byte{}, 0644); err != nil {
panic(err)
}
}

View File

@ -1,9 +1,25 @@
const path = require('path');
const fs = require('fs')
// This should be a file created by gold_test_env.go which contains the port number
// on which it is listening. For whatever reason, karma was not happy serving the
// port file directly, but reading it in and then adding it as a proxy seems to
// work fine.
const testOnEnvPortPath = path.join(process.env['ENV_DIR'], 'port');
const port = fs.readFileSync(testOnEnvPortPath, 'utf8').toString();
console.log('test_on_env PORT:', port);
module.exports = function(config) {
// http://karma-runner.github.io/6.3/config/configuration-file.html
let cfg = {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
proxies: {
// The tests will make calls to /gold_rpc/whatever and they will be redirected
// to the correct location.
'/gold_rpc/': `http://localhost:${port}/`,
},
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
@ -23,7 +39,7 @@ module.exports = function(config) {
// - browsers
// - basePath
// - singleRun
BAZEL_APPLY_SETTINGS(cfg)
BAZEL_APPLY_SETTINGS(cfg);
config.set(cfg);
};

View File

@ -3,7 +3,7 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
let CanvasKit = null;
const LoadCanvasKit = new Promise((resolve, reject) => {
const _LoadCanvasKit = new Promise((resolve, reject) => {
console.log('canvaskit loading', new Date());
CanvasKitInit({
locateFile: (file) => '/static/skia/modules/canvaskit/canvaskit_wasm/'+file,
@ -15,4 +15,20 @@ const LoadCanvasKit = new Promise((resolve, reject) => {
console.error('canvaskit failed to load', new Date(), e);
reject();
});
});
});
const _TestReportServer = new Promise((resolve, reject) => {
fetch('/gold_rpc/healthz').then((resp) => {
if (resp.ok) {
resolve();
return;
}
console.log('/healthz returned non 200 code')
reject();
}).catch((e) => {
console.log('Server for reporting results was not up', e)
reject();
});
});
const EverythingLoaded = Promise.all([_LoadCanvasKit, _TestReportServer]);

View File

@ -6,14 +6,40 @@ describe('The test harness', () => {
expect(null).toBeFalsy();
});
describe('the CanvasKit loading promise', () => {
describe('the EverythingLoaded promise', () => {
beforeEach(async () => {
await LoadCanvasKit;
await EverythingLoaded;
});
it('has access to CanvasKit', () => {
const r = CanvasKit.LTRBRect(1, 2, 3, 4);
expect(r.constructor.name).toEqual('Float32Array');
});
it('can talk to Gold once', async () => {
const payload = {
name: 'test_001',
b64_data: btoa('This could have been a PNG_' + (new Date().toLocaleString()))
}
const resp = await fetch('/gold_rpc/report', {
body: JSON.stringify(payload),
method: 'POST',
});
expect(resp.status).toEqual(201); // StatusCreated
});
it('can talk to Gold twice', async () => {
const payload = {
name: 'test_002',
b64_data: btoa('This is some other data ' + (new Date().toLocaleString()))
}
const resp = await fetch('/gold_rpc/report', {
body: JSON.stringify(payload),
method: 'POST',
});
expect(resp.status).toEqual(201); // StatusCreated
});
});
})
})

View File

@ -3762,6 +3762,7 @@ generated_cc_atom(
"//include/core:SkShader_hdr",
"//include/private:SkTo_hdr",
"//src/shaders:SkShaderBase_hdr",
"//src/utils:SkBlitterTrace_hdr",
],
)
@ -5186,6 +5187,7 @@ generated_cc_atom(
"//include/private:SkImageInfoPriv_hdr",
"//include/private:SkMacros_hdr",
"//src/shaders:SkColorFilterShader_hdr",
"//src/utils:SkBlitterTrace_hdr",
],
)

View File

@ -78,6 +78,7 @@ generated_cc_atom(
hdrs = ["GrSDFTControl.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkFlattenable_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkScalar_hdr",
],
@ -96,6 +97,7 @@ generated_cc_atom(
"//include/core:SkScalar_hdr",
"//include/core:SkSurfaceProps_hdr",
"//src/core:SkGlyphRunPainter_hdr",
"//src/core:SkReadBuffer_hdr",
],
)
@ -163,14 +165,18 @@ generated_cc_atom(
deps = [
":GrAtlasManager_hdr",
":GrGlyphVector_hdr",
":GrSDFTControl_hdr",
":GrStrikeCache_hdr",
":GrTextBlob_hdr",
"//include/core:SkColorFilter_hdr",
"//include/core:SkScalar_hdr",
"//include/gpu:GrRecordingContext_hdr",
"//include/private:SkTemplates_hdr",
"//include/private/chromium:GrSlug_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
"//src/core:SkEnumerate_hdr",
"//src/core:SkFontPriv_hdr",
"//src/core:SkGlyph_hdr",
"//src/core:SkMaskFilterBase_hdr",
"//src/core:SkMatrixProvider_hdr",
"//src/core:SkPaintPriv_hdr",

View File

@ -1168,6 +1168,7 @@ generated_cc_atom(
hdrs = ["SkTypeface_win_dw.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkFontArguments_hdr",
"//include/core:SkTypeface_hdr",
"//src/core:SkAdvancedTypefaceMetrics_hdr",
"//src/core:SkLeanWindows_hdr",

View File

@ -362,6 +362,7 @@ generated_cc_atom(
"//include/core:SkSpan_hdr",
"//include/private:SkSLModifiers_hdr",
"//include/private:SkSLSymbol_hdr",
"//include/private:SkTFitsIn_hdr",
"//include/private:SkTHash_hdr",
],
)
@ -703,6 +704,7 @@ generated_cc_atom(
"//include/private:SkSLStatement_hdr",
"//src/sksl/ir:SkSLBinaryExpression_hdr",
"//src/sksl/ir:SkSLBreakStatement_hdr",
"//src/sksl/ir:SkSLConstructorArrayCast_hdr",
"//src/sksl/ir:SkSLConstructorArray_hdr",
"//src/sksl/ir:SkSLConstructorCompoundCast_hdr",
"//src/sksl/ir:SkSLConstructorCompound_hdr",

View File

@ -660,3 +660,23 @@ generated_cc_atom(
"//src/core:SkStreamPriv_hdr",
],
)
generated_cc_atom(
name = "SkBlitterTraceCommon_hdr",
hdrs = ["SkBlitterTraceCommon.h"],
visibility = ["//:__subpackages__"],
deps = [":SkCycles_hdr"],
)
generated_cc_atom(
name = "SkBlitterTrace_hdr",
hdrs = ["SkBlitterTrace.h"],
visibility = ["//:__subpackages__"],
deps = [":SkBlitterTraceCommon_hdr"],
)
generated_cc_atom(
name = "SkCycles_hdr",
hdrs = ["SkCycles.h"],
visibility = ["//:__subpackages__"],
)