4d6d9e3f89
2 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Kevin Lubick
|
1fc0c1c0f8 |
[canvaskit] Run JS tests in Bazel
This CL makes a copy of all the files in //modules/canvaskit/tests/ and puts them into //modules/canvaskit/tests/bazel. They are slightly modified to run in Bazel (renamed to be more clear what they are and using EverythingLoaded instead of CanvasKitLoaded). The original files will be deleted when we no longer test CanvasKit outside of Bazel. Suggested Review Order: - hello_world.js is now smoke_test.js. That test polls the gold_test_env server, but does not create an image. - test_reporter.js which is much simplified from the non-Bazel version (due to the removal of a bunch of PathKit stuff). These JS tests are not the C++ gms. This means that we need to capture the PNG ourselves, which we do using the <canvas> API toDataURL(). This is base64 encoded, which is conveniently the format accepted by the gold_test_env server. - karma.bazel.js and assets/BUILD.bazel which make all the test assets available under a shortened path /assets. - Feel free to skip over the remaining *_test.js, as they are basically the same as what is currently checked in, just with the modifications above. - Any remaining files. Change-Id: I45fc38da38faf11f21011e7381d390e6bb299df4 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/513916 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> |
||
Kevin Lubick
|
acab911351 |
[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> |