Bazel binary size: add a regression test
Add a regression test for the size of the Bazel
binary, by asserting the number of embedded tools.
Sudden, unexpectedly large changes in the number
of embedded tools can be indicative of an
unintentional addition/removal of embedded tools
and unexpected growth/shrinkage of the Bazel
binary.
Fixes https://github.com/bazelbuild/bazel/issues/5378
Change-Id: I7880f4544c560eb627ef5fb8a55ff1b377ec156b
Closes #5399.
Change-Id: I10c8cdcd5e675cbc0bac43003741a8af27248992
PiperOrigin-RevId: 201318396
diff --git a/src/BUILD b/src/BUILD
index 4b96719..551e23b 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -1,6 +1,7 @@
# Packaging
load(":embedded_tools.bzl", "srcsfile")
+load(":rule_size_test.bzl", "rule_size_test")
md5_cmd = "set -e -o pipefail && cat $(SRCS) | sort | %s | awk '{ print $$1; }' > $@"
@@ -182,6 +183,16 @@
"_nojdk",
]]
+rule_size_test(
+ name = "embedded_tools_size_test",
+ src = ":embedded_tools_srcs",
+ # WARNING: Only adjust the number in `expect` if you are intentionally
+ # adding or removing embedded tools. Know that the more embedded tools there
+ # are in Bazel, the bigger the binary becomes and the slower Bazel starts.
+ expect = 503,
+ margin = 5, # percentage
+)
+
filegroup(
name = "embedded_jdk",
srcs = select({