Reland "[bazel] Add individual test targets, broken up by CPU and GPU"
This is a reland of commit e034091e5451b3dc879357c3fa48d00a8bed4f8b
Original change's description:
> [bazel] Add individual test targets, broken up by CPU and GPU
>
> Trimmed down testing output:
>
> $ bazel test //tests/... --config=gl
> //tests:GPUDrawPathTest PASSED in 0.6s
> //tests:MatrixProcsTest PASSED in 0.1s
>
> $ bazel test //tests/... --config=cpu
> //tests:GPUDrawPathTest PASSED in 0.0s
> //tests:MatrixProcsTest PASSED in 0.1s
>
> # Make small change to tests/MatrixProcsTest.cpp
>
> $ bazel test //tests/... --config=cpu
> //tests:GPUDrawPathTest (cached) PASSED in 0.0s
> //tests:MatrixProcsTest PASSED in 0.1s
>
> # Compile and run CPU tests remotely on Linux RBE instances;
> bazel test //tests/... --config=linux_rbe --config=cpu --remote_download_minimal
> INFO: Elapsed time: 54.482s, Critical Path: 45.77s
> INFO: 1320 processes: 112 remote cache hit, 1583 remote.
> INFO: Build completed, 1 test FAILED, 1320 total actions
> //tests:TypefaceMacTest SKIPPED
> //tests:AAClipTest PASSED in 2.2s
> ...
> //tests:YUVTest PASSED in 1.7s
> //tests:TypefaceTest FAILED in 1.7s
>
> (I think the TypefaceTest is failing remotely because the
> RBE instances might not have any fonts installed in the
> Docker container).
>
> All test files in the tests subfolder (but not //tests/graphite
> or //tests/sksl) are categorized as Ganesh GPU tests or CPU tests.
> This categorization is based on the question "Do we need a Ganesh
> GPU backend to compile the test file or not?".
>
> These are further grouped into tests that need similar features
> enabled, for example CODEC_TESTS and PDF_TESTS. Features are
> enabled via a new transition rule cc_test_with_flags, which is
> very similar to cc_binary_with_flags.
>
> These groups are turned into Bazel targets using macros defined
> in //tests/test.bzl (basically just a for loop and some select
> statements).
>
> Bazel does not let us define some tests when certain --config
> options are made (at least, not with macros), so we always
> define every test target. We do use select() statements to
> decide if this test should do something (that is, run Skia and
> do assertions) or not (just return 0). This is based off one of
> the options passed into --config. For example --config=cpu
> only *really* runs the tests which do not need a GPU backend
> (e.g. CODEC_TESTS, PDF_TESTS, and more). --config=gl compiles
> in the Ganesh GL backend and runs the tests that require a
> GPU backend.
>
> bazel/buildrc has some configs for testing one GPU backend
> at a time, as this is how we currently have our CI jobs
> organized. Local developers could define their own settings
> with multiple backends as necessary and use that for a
> --config instead.
>
> Known Limitations:
> - CPU tests all pass for me locally. One fails remotely.
> - Some (~12) GPU tests fail locally. Have not delved into why yet.
> - We do not (yet) enforce IWYU on all the tests. I would like to,
> but that's for another time due to the large amount of files
> that would need changing.
> - Have only run the tests on a Linux box so far.
>
> Suggested Review Order:
> - //tests/test.bzl, noting the select() statements that
> compile BazelTestRunner.cpp etc or BazelNoopRunner.cpp
> - //tests/BUILD.bazel to see the breakdown and usages of
> the macros.
> - //tests/Bazel*Runner.cpp, noting some similarities to how
> dm/DM.cpp works (it was what I looked at when building this).
> - //bazel/cc_test_with_flags.bzl, noting how it uses the same
> list from cc_binary_with_flags.bzl.
> - .bazelproject, which makes integration with Intellij a little
> bit easier (but this could use some tweaks).
> - All the other BUILD.bazel files, noting how we needed a few
> more settings to make all the tests compile correctly
> (e.g. //src/lazy:enable_discardable_memory and the fontmgrs).
> - All other files.
>
> Change-Id: I39d4dcbf03e45d31c3d9bea3a4eb04cd08cb0b05
> Bug: skia:13758
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/583247
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Bug: skia:13758
Change-Id: Ib705dd1b6b411209628503b371b5c3b7ad24d2a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/588040
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
30 files changed