Add coverage tools to android_local_test - #561
Closed
bala-evani-ai wants to merge 1292 commits into
Closed
bala-evani-ai wants to merge 1292 commits into
bala-evani-ai wants to merge 1292 commits into
Conversation
This is no longer used. PiperOrigin-RevId: 789834250 Change-Id: I1efdfeb8420321b844cc34e6b00d4c968a0feeb6
…ort lint checks. PiperOrigin-RevId: 789941748 Change-Id: I501c1317dff6a0f07fbb2edda93c276d9c08f546
These current have no effect. PiperOrigin-RevId: 791009415 Change-Id: Ic917e057f09238296bf71a6f1f43598feddd5dc6
PiperOrigin-RevId: 791282005 Change-Id: If14f9dfec164b23abd3736c875e7e51eceb6cc25
The default path prevents the $PATH search logic in the broker library from functioning. This should obviate bazelbuild#350, as long as users have `adb` somewhere in $PATH. Closes bazelbuild#398 COPYBARA_INTEGRATE_REVIEW=bazelbuild#398 from ted-xie:no_default_adb aef38a6 PiperOrigin-RevId: 791322866 Change-Id: I3f1c75fa8027a4a59d85670b62cb08f92ae1736a
This has been replaced with the java-based DesugarDexShardingAction. PiperOrigin-RevId: 791667701 Change-Id: Ieabd4507766ea419b5326348e5a2ebdf9e1f4d67
Closes bazelbuild#395 COPYBARA_INTEGRATE_REVIEW=bazelbuild#395 from ted-xie:test_just_protobuf 4df7e92 PiperOrigin-RevId: 792606003 Change-Id: I0107dd0a96ac7e477154a1ed5fa21dad988eb73b
…azel ... instead of `@bazel_tools`. This should fix breakages with bazel at HEAD. Closes bazelbuild#394 COPYBARA_INTEGRATE_REVIEW=bazelbuild#394 from ted-xie:use_new_protos 7ee7647 PiperOrigin-RevId: 792680788 Change-Id: Idff76c73392bc3cdde51444775d9541f21cce132
Closes bazelbuild#399 COPYBARA_INTEGRATE_REVIEW=bazelbuild#399 from ted-xie:last_green_protobuf_fixed 6026668 PiperOrigin-RevId: 792700426 Change-Id: I3176c32c19e2a9e5d9e357b017e606f4c6568f2d
PiperOrigin-RevId: 792712421 Change-Id: I6f511d3d1f6288b80b411cd2dd713508aca710fd
…provided manifest PiperOrigin-RevId: 793618880 Change-Id: Ie1d9d3f42f40135e826ce403661b0fd114abe460
This change removes the dependency on `absl.app` and `absl.flags`, replacing them with the standard `argparse` module for command-line argument parsing. PiperOrigin-RevId: 793727840 Change-Id: I420802d7a45cf9a8cfa1051aa39ad5f122c80a15
* Revise the recommended bazel version in README.md * Add a disclaimer in the README for protobuf C++ minimum version * Add more detail to bzlmod rules_android setup in the release notes. PiperOrigin-RevId: 793810183 Change-Id: I6b5fbf3e7c24f7be7d7e87506dfd6b11d86a2d31
…list Should no longer be necessary in newer Bazel versions. Closes bazelbuild#401 COPYBARA_INTEGRATE_REVIEW=bazelbuild#401 from ted-xie:no_transition_allowlist fe938e9 PiperOrigin-RevId: 793811175 Change-Id: Id422fdc5a2020764a130409c5528ca2c05b41db2
publish.yaml -> publish.yml https://github.com/bazelbuild/rules_android/blob/main/.github/workflows/publish.yml PiperOrigin-RevId: 794213424 Change-Id: I9221924076aa20d977487003ee514ed88c43d57d
Closes bazelbuild#404 COPYBARA_INTEGRATE_REVIEW=bazelbuild#404 from ted-xie:release_yml 02afd00 PiperOrigin-RevId: 794243221 Change-Id: Ieaa3cc97297309836182120ffa45abb69a69321d
PiperOrigin-RevId: 794544587 Change-Id: Id8bc7f93921cc15eb7ecebaacad100cbb1651c13
…brary Also removes a no-longer-necessary abseil dep. Closes bazelbuild#405 COPYBARA_INTEGRATE_REVIEW=bazelbuild#405 from ted-xie:bash_runfiles c218142 PiperOrigin-RevId: 794617718 Change-Id: I27ce9e11270066a297f98acd3c92a88006d1f641
…proguard outputs from `ctx.outputs` Fixes bazelbuild#343 Closes bazelbuild#344 COPYBARA_INTEGRATE_REVIEW=bazelbuild#344 from pswaminathan:p/stacked/fix-proguard-outputs cdbd9ff PiperOrigin-RevId: 794620428 Change-Id: I5c06fb7fb8bb1d5c865c2c1e09fd3dbb8f207ed4
…rules_android Closes bazelbuild#402 COPYBARA_INTEGRATE_REVIEW=bazelbuild#402 from ted-xie:darwin_conditions 54d8b16 PiperOrigin-RevId: 794685810 Change-Id: I15d6de2e5e04bc1e5a1650f3d3cd8338122c9b5f
PiperOrigin-RevId: 794696262 Change-Id: Ic9f70a61e8a04062f3c168e707fab7d9540764a4
…ls/jdk` Closes bazelbuild#406 COPYBARA_INTEGRATE_REVIEW=bazelbuild#406 from ted-xie:no_bazel_tools_jdk 1677235 PiperOrigin-RevId: 794723027 Change-Id: I12b0f1b975ed2d9f351e557d8883b93b3b58f5f8
…ls/cpp`. Closes bazelbuild#409 COPYBARA_INTEGRATE_REVIEW=bazelbuild#409 from ted-xie:no_bazel_tools_cpp 94213b9 PiperOrigin-RevId: 796433155 Change-Id: I7b24b271f4e890b1c861680f9455651f7154c9d9
…ependency on SDK home envvar Per https://bazel.build/rules/lib/builtins/repository_os.html#environ: > NOTE: Retrieving an environment variable from this dictionary does not establish a dependency from a repository rule or module extension to the environment variable. To establish a dependency when looking up an environment variable, use either repository_ctx.getenv or module_ctx.getenv instead. Analogous to bazelbuild/rules_android_ndk#102 Closes bazelbuild#408 COPYBARA_INTEGRATE_REVIEW=bazelbuild#408 from pswaminathan:p/stacked/ctx-getenv-sdk-home 13955c8 PiperOrigin-RevId: 796445190 Change-Id: If87352526742ef1edbcf8dc5c53b3532ff04d239
... instead of the ijar zipper. NOTE: This change will create some minor APK diffs, since the zip entries for the baseline profiles have slightly different metadata: * Zip spec version (from 0.0 to 2.0) * Filesystem type (from 'unx' to 'FAT') * Baseline profile files no longer executable. PiperOrigin-RevId: 796851818 Change-Id: Ie171348a6b26c6bca571b7bc169df2ccd3b05db3
PiperOrigin-RevId: 796974818 Change-Id: Ic7d3fa3e30e1904e441785ada4ae09adc610489c
PiperOrigin-RevId: 797889007 Change-Id: Ib88265f20cfc1e569449ba2753c64f3e9ac34733
PiperOrigin-RevId: 799690958 Change-Id: I8d58ffe45a80665311b0ca496fd181c7db7e1212
Will be used to define common JVM options for java_binary targets. PiperOrigin-RevId: 800603118 Change-Id: If36ba348bdd6963b0176e4bd8dc82db14550f277
PiperOrigin-RevId: 800954378 Change-Id: If55bec91ea4b6741e789dfe55d3687e9125b1f88
This ensures identical MANIFEST.MF headers across module splits and avoids Bundletool entry clashes. PiperOrigin-RevId: 959227250 Change-Id: I26806b4141e7d60a41ffd40fa6587f2153e20010
aapt2 optimize aims to reduce APK size by 1-3%, an unnecessary step for test builds where file size is not a priority. Thus, we can extend optimize_throughput to skip aapt2 optimize, supporting the flag's functionality of trading file size optimizations for faster execution. PiperOrigin-RevId: 959242802 Change-Id: Ifa4141ea48839a40a519f2507adf8151bc9045f0
The main impactful change is removing `--no-optimize` from _DEXOPTS_SUPPORTED_IN_INCREMENTAL_DEXING. This list is used by the dex_desugar_aspect. A set of dexing actions is created for each combination of dexopts. In `android_binary` we just pull the outputs from the actions with the set of dexopts matching the value passed to the dexopts attribute of the `android_binary` target. So we create many sets of actions that are never executed. This is a waste of Blaze heap. The `--no-optimize` flag is completely ignored CompatDexBuilder which is the wrapper we use around D8 to trigger dexing. This means removing the no-op dexopt cuts the number of dexing actions generated by the dex_desugar_aspect in half with no functional impact. PiperOrigin-RevId: 959735674 Change-Id: I0d2db2102b1826c366c51f7466d927219f46e54a
Starting from version 0.8.0, rules_android will start (incrementally) supporting Starlark-equivalent flags to former Bazel-native Android flags. PiperOrigin-RevId: 959773334 Change-Id: If670a8d234e38510b048e901d1bc1326f92abdd4
PiperOrigin-RevId: 959897613 Change-Id: I030dfb375ed4d3c8fcc84da4d25be22b7acb43bb
The new `-Othroughput` aapt2 option uses faster level 1 zlib compression instead of level 9. This is faster when building transient android binaries for instrumentation tests or for local development. PiperOrigin-RevId: 960082841 Change-Id: I0a6ebe1f0aafba19fe1062833ac741369ee0615a
PiperOrigin-RevId: 960399120 Change-Id: Ib240b4681f199b09f094a7c35ecca73779fbba6f
PiperOrigin-RevId: 963585067 Change-Id: I9569bb4007e347eeff9ef266ebf7880e0068ddb0
In CL 959227250, output_jar_creator was defaulted to "bazel" in rules/java.bzl:singlejar, and removed from rules/android_binary/impl.bzl. However, rules/apk_packaging.bzl still defaulted output_jar_creator = "" in _process() and output_jar_creator = None in _build_apk(), and forwarded the argument to java.singlejar(). Because rules/java.bzl checks `if output_jar_creator:`, passing "" or None caused the "bazel" default to be bypassed for base module packaging, producing "Created-By: singlejar" (48 bytes). Feature modules, which call java.singlejar() directly, picked up "Created-By: bazel" (44 bytes), triggering Bundletool EntryClashValidator InvalidBundleException. Defaulting output_jar_creator = "bazel" in both _process() and _build_apk() ensures consistent 44-byte MANIFEST.MF headers across all module splits. PiperOrigin-RevId: 967283865 Change-Id: I3bfe26031f086a23cd2912bc07e2452604668952
This is currently a no-op in bazel, as its restricted to the existing com.google.testing.junit.runner.GoogleTestRunner PiperOrigin-RevId: 968590656 Change-Id: I8d61a0b89d830e985dc591fcddb4a03b8fa7db8c
Adds instructions to guide users on how to configure R8 optimization in their BUILD file using the android_binary target. It explains the proguard_specs, shrink_resources, and proguard_generate_mapping attributes, and provides instructions for building the optimized APK. PiperOrigin-RevId: 968680246 Change-Id: If03ab0473b63814467a52457d0151f9321b0e986
This change adds a new example project under examples/r8-optimized to demonstrate building an Android application with R8 optimization and resource shrinking enabled. The example includes both android_binary and android_application targets, along with their corresponding ProGuard configuration files. PiperOrigin-RevId: 970172709 Change-Id: I916a6de5e2600b3891d3bd271d2619b2db4f7ba7
Updates the URL for the proguard-android-optimize.txt file to point to the rules_android repository instead of the bazelbuild examples repository. PiperOrigin-RevId: 970473584 Change-Id: Ia24d96411a1e64b133c7cd57f38ef82169af44a4
…ngs_output_file as implicit_outputs [Isssue](bazelbuild#546) Closes bazelbuild#547 COPYBARA_INTEGRATE_REVIEW=bazelbuild#547 from vadymsavchenko-lyft:r8-proguard-map-default-output 744ce6d PiperOrigin-RevId: 970769691 Change-Id: If62478c0db8915bc7bc5d60d7aaf8ccf4d32876c
PiperOrigin-RevId: 971491679 Change-Id: I26c9eecc53904abbe457c10473b4cafb8331f229
…pping colliding class names ## Problem `DexFileSplitter` stores input entries in a `TreeMap` using `ZipEntryComparator::compareClassNames`, then inserts them with `putIfAbsent`. The comparator replaces `$` with `0` before comparing names. When generated nested class names include entries such as `Foo$2$1$1.class.dex` and `Foo$2$101.class.dex`, both normalize to the same value. The comparator therefore returns zero, the `TreeMap` treats the distinct classes as the same key, and `putIfAbsent` silently drops one. The resulting APK can fail at runtime with `NoClassDefFoundError` for the missing class. ## Change Keep the existing dx-style normalized ordering. When two normalized names compare equal, fall back to comparing the original names so distinct entries remain distinct. No ordering changes for names whose normalized forms differ. Add regression coverage that inserts the colliding names into the same `TreeMap` shape used by `DexFileSplitter` and verifies that both remain present. ## Testing - Passed a self-contained `javac` regression check against the modified `ZipEntryComparator`. - Added the collision case to `DexFileSplitterTest`. - Attempted `bazel test //src/tools/javatests/com/google/devtools/build/android/dexer:AllTests --test_output=errors`; repository analysis could not complete locally because connections to `maven.google.com` timed out before compilation or test execution. Closes bazelbuild#548 COPYBARA_INTEGRATE_REVIEW=bazelbuild#548 from oscarthecat:fix/dex-splitter-class-name-collision 140e6c0 PiperOrigin-RevId: 971560232 Change-Id: Iba7facbdb7e7c4d784560bb0b359132d5c7c552f
This allows the remote repo contents cache to cache the result of this repo Closes bazelbuild#537 COPYBARA_INTEGRATE_REVIEW=bazelbuild#537 from keith:ks/return-repo-extension-metadata-from-rules a514acb PiperOrigin-RevId: 971999361 Change-Id: I443f368773beda9f3c8bc5c174de9c7ae3364b93
This defaults to True, and any attempt to set it is a failure. Anyone who wants fusing behavior changed should configure this by passing a feature manifest (which is a requirement for most android_feature_modules). PiperOrigin-RevId: 972222221 Change-Id: I5d585f5a95b84b30564dbde200bd07fb204fd44b
…on actions. The main change is adding the new execution requirement. There are two sets of other changes. 1. In dex_desugar_aspect.bzl switch from using `jar.path` to `jar.short_path` when declaring the bytecode transformer output file. Using `path` includes configuration information which breaks when the path is rewritten as part of path mapping. This change looks safe as every other use in the same file uses `jar.short_path` anyway. 2. Update the android_bytecode_transormer call to skip using the script template with a string format. Using the string format requires embedding the paths into the script. Those paths are invalid under path mapping. Path mapping only works when Files are passed via args.add() methods. Additionally skip explicitly creating the flag file and let Blaze handle it with args.use_param_file(). I'm not enabling path mapping for the dex actions triggered in `android_binary` itself. These actions are more complicated to migrate due to a few factors like param file usage and the tree artifact/spawn action template setup. I changed the progress_message for DesugarDexSharding in mobile-install since the full path including the configuration isn't very useful for understanding build progress. PiperOrigin-RevId: 972235479 Change-Id: I958fe4e45819a2aef94f18dd8dab392482977b0a
…_cycle_shrinking, --experimental_android_compress_java_resources Delete android_manifest_merger references #FLAG_CHANGE PiperOrigin-RevId: 972777320 Change-Id: I9bbbd5da407875e23e3162eb666b11919cccbc99
The old include_prefixes list for the extras jar was copied from Bazel, which copied it from an uptstream project years ago. The list is now outdated and does not work for newer JDK versions. This change copies the list from a Google-internal upstream project. This obviates bazelbuild#555. Change-Id: Idab4efdb2e6c97acd504d79c4bd800be6acc86d7 Closes bazelbuild#556 COPYBARA_INTEGRATE_REVIEW=bazelbuild#556 from ted-xie:update-java-extras-jar ed344b1 PiperOrigin-RevId: 974707380
…idex sharding. PiperOrigin-RevId: 974808907 Change-Id: Iedb642b5afd9ecab1abd34b8e641553d89a441b6
…or rules_android 0.7.3 bazelbuild#351 The getting started snippet still pinned WORKSPACE to 0.6.0-alpha1 (yanked on BCR) and bzlmod to 0.6.5. I updated both to 0.7.3, put bzlmod first, and pointed at examples/basicapp. Fixes bazelbuild#351 Closes bazelbuild#559 COPYBARA_INTEGRATE_REVIEW=bazelbuild#559 from AzazelSensei:docs/update-getting-started-351 4f82137 PiperOrigin-RevId: 975248073 Change-Id: I35c66d50d4c9ee2ff598d61e8553e478824c5941
…azelbuild#547 bazelbuild#547 modified the R8 rule's implicit outputs. This change adds an analysis test to verify that change. Closes bazelbuild#551 COPYBARA_INTEGRATE_REVIEW=bazelbuild#551 from ted-xie:r8-implicit-output-unit-test fea2960 PiperOrigin-RevId: 975249246 Change-Id: I85c93afb5ddebd0b81f1f613c10a52a38de70bb4
…L` optimizer action. * `rules/android_binary/impl.bzl`: Declare `_proguard.why_keeping` file artifact. * `rules_android/test/rules/android_binary/BUILD`: Update golden test implicit output assertions. PiperOrigin-RevId: 975406738 Change-Id: Idb5cfb473311f5e703b27d627ec648dd52785785
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
If this approach looks good, I can add an end-to-end test that runs Bazel coverage and checks that the generated LCOV report contains execution data. |
bala-evani-ai
force-pushed
the
fix-android-local-test-coverage
branch
from
September 4, 2026 18:59
da8957a to
15881a0
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running
bazel coverageon a Starlarkandroid_local_testlookssuccessful, but it does not collect execution coverage.
The test passes and the combined report contains a synthetic baseline
record, but the per-test
coverage.datis empty. This happens becauseandroid_local_testreturnsInstrumentedFilesInfowithout definingthe coverage tools expected by Bazel test rules.
When
_lcov_mergeris missing, Bazel'scollect_coverage.shsees thatLCOV_MERGERis unset and exits without processing the intermediatecoverage data.
Change
Add
_lcov_mergerand_collect_cc_coveragetoandroid_local_test, following Bazel's documented setup for test rulecoverage.
Testing
Ran:
bazel test //test/rules/android_local_test/...All 16 tests passed.
Also ran:
Before this change, the per-test report was empty and the combined
report had
LF:0andLH:0.After this change, the per-test report contains the expected source
record and the combined report has
LF:8andLH:8.Fixes #560
Related to #558