forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[bazel] Add individual test targets, broken up by CPU and GPU"
This is a reland of commit e034091 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 <[email protected]> > Reviewed-by: Leandro Lovisolo <[email protected]> Bug: skia:13758 Change-Id: Ib705dd1b6b411209628503b371b5c3b7ad24d2a4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/588040 Reviewed-by: Leandro Lovisolo <[email protected]> Reviewed-by: Ben Wagner <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,511 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
directories: | ||
. | ||
-bin | ||
-out | ||
-node_modules | ||
-third_party/externals | ||
|
||
# Automatically includes all relevant targets under the 'directories' above | ||
derive_targets_from_directories: false | ||
|
||
targets: | ||
# If source code isn't resolving, add additional targets that compile it here | ||
//example:hello_world_vulkan | ||
//example:hello_world_gl | ||
additional_languages: | ||
# Uncomment any additional languages you want supported | ||
javascript | ||
python | ||
typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
THIS IS THE EXTERNAL-ONLY VERSION OF THIS FILE. G3 HAS ITS OWN. | ||
This file contains a way to set flags from BUILD.bazel instead of requiring users to set them from | ||
the CLI. This allows us to have tests that build with a specific set of features (e.g. the pdf | ||
backend or the codecs) without having a large number of flags to set (easier to forget). | ||
It uses the same core implementation as cc_binary_with_flags. | ||
It is based off of: | ||
https://github.com/bazelbuild/examples/blob/7fc3f8b587ee415ff02ce358caa960f9533a912c/configurations/cc_test/defs.bzl | ||
""" | ||
|
||
load("//bazel:copts.bzl", "DEFAULT_COPTS") | ||
load("//bazel:cc_binary_with_flags.bzl", "with_flags_transition") | ||
|
||
def _transition_rule_impl(ctx): | ||
executable_src = ctx.executable.actual_test | ||
executable_dst = ctx.actions.declare_file(ctx.label.name) | ||
ctx.actions.run_shell( | ||
tools = [executable_src], | ||
outputs = [executable_dst], | ||
command = "cp %s %s" % (executable_src.path, executable_dst.path), | ||
) | ||
runfiles = ctx.attr.actual_test[0][DefaultInfo].default_runfiles | ||
return [DefaultInfo(runfiles = runfiles, executable = executable_dst)] | ||
|
||
# This rule must end with a _test suffix or Bazel doesn't allow the test attribute to be true. | ||
transition_test = rule( | ||
implementation = _transition_rule_impl, | ||
attrs = { | ||
# set_flags is a dictionary with the keys being the short-form of a flag name | ||
# (e.g. the part that comes after the colon) and the value being a list of values | ||
# that the flag should be set to, regardless of the relevant CLI flags. | ||
# https://bazel.build/rules/lib/attr#string_list_dict | ||
"set_flags": attr.string_list_dict(), | ||
# This is the cc_test that should be made with the flags being set. | ||
# Note specifically how it is modified using with_flags_transition, which | ||
# ensures that the flags propagates down the graph. Must be executable | ||
# so the _transition_rule_impl can use it as an executable. | ||
# https://bazel.build/rules/lib/attr#label | ||
"actual_test": attr.label(cfg = with_flags_transition, executable = True), | ||
# This is a stock Bazel requirement for any rule that uses Starlark | ||
# transitions. It's okay to copy the below verbatim for all such rules. | ||
# | ||
# The purpose of this requirement is to give the ability to restrict | ||
# which packages can invoke these rules, since Starlark transitions | ||
# make much larger graphs possible that can have memory and performance | ||
# consequences for your build. The allowlist defaults to "everything". | ||
# But you can redefine it more strictly if you feel that's prudent. | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist", | ||
), | ||
}, | ||
# Means it works with "$ bazel test". https://bazel.build/rules/lib/globals#rule.test | ||
test = True, | ||
) | ||
|
||
def cc_test_with_flags(name, set_flags = {}, copts = DEFAULT_COPTS, **kwargs): | ||
"""Builds a cc_test as if set_flags were set on the CLI. | ||
Args: | ||
name: string, the name for the rule that is the binary, but with the flags changed via | ||
a transition. Any dependents should use this name. | ||
set_flags: dictionary of string to list of strings. The keys should be the name of the | ||
flag, and the values should be the desired valid settings for that flag. | ||
copts: a list of strings or select statements that control the compiler flags. | ||
It has a sensible list of defaults. | ||
**kwargs: Any flags that a cc_binary normally takes. | ||
""" | ||
cc_test_name = name + "_native_test" | ||
transition_test( | ||
name = name, | ||
actual_test = ":%s" % cc_test_name, | ||
set_flags = set_flags, | ||
testonly = True, | ||
) | ||
tags = kwargs.get("tags", []) | ||
tags.append("manual") # We want to exclude this helper test from bazel test foo/... | ||
kwargs["tags"] = tags | ||
native.cc_test( | ||
name = cc_test_name, | ||
copts = copts, | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
load("//bazel:macros.bzl", "exports_files_legacy") | ||
load("//bazel:macros.bzl", "exports_files_legacy", "select_multi") | ||
|
||
licenses(["notice"]) | ||
|
||
exports_files_legacy() | ||
|
||
filegroup( | ||
name = "fontmgr", | ||
srcs = select_multi( | ||
{ | ||
"//bazel/common_config_settings:uses_android_fontmgr": ["SkFontMgr_android.h"], | ||
"//bazel/common_config_settings:uses_custom_directory_fontmgr": ["SkFontMgr_directory.h"], | ||
"//bazel/common_config_settings:uses_custom_empty_fontmgr": ["SkFontMgr_empty.h"], | ||
"//bazel/common_config_settings:uses_fontconfig_fontmgr": ["SkFontMgr_fontconfig.h"], | ||
"//bazel/common_config_settings:uses_fci_fontmgr": [ | ||
"SkFontConfigInterface.h", | ||
"SkFontMgr_FontConfigInterface.h", | ||
], | ||
# TODO(kjlubick, bungeman) fuchsia_fontmgr, fontmgr_mac_ct, fontmgr_win | ||
}, | ||
), | ||
) | ||
|
||
filegroup( | ||
name = "public_hdrs", | ||
srcs = [ | ||
"SkCFObject.h", | ||
"SkFontConfigInterface.h", | ||
"SkFontMgr_FontConfigInterface.h", | ||
"SkFontMgr_android.h", | ||
"SkFontMgr_directory.h", | ||
"SkFontMgr_empty.h", | ||
"SkFontMgr_fontconfig.h", | ||
"SkFontMgr_fuchsia.h", | ||
"SkFontMgr_indirect.h", | ||
"SkFontMgr_mac_ct.h", | ||
"SkImageGeneratorCG.h", | ||
"SkImageGeneratorNDK.h", | ||
"SkImageGeneratorWIC.h", | ||
"SkRemotableFontMgr.h", | ||
"SkTypeface_mac.h", | ||
"SkTypeface_win.h", | ||
], | ||
":fontmgr", | ||
] + select({ | ||
"@platforms//os:macos": ["SkCFObject.h"], | ||
"@platforms//os:ios": ["SkCFObject.h"], | ||
"//conditions:default": [], | ||
}) + select({ | ||
"@platforms//os:macos": ["SkTypeface_mac.h"], | ||
"@platforms//os:windows": ["SkTypeface_win.h"], | ||
"//conditions:default": [], | ||
}), | ||
visibility = ["//include:__pkg__"], | ||
) |
Oops, something went wrong.