Reusable Android/Kotlin/Robolectric suite macro that scans many test files and generates per-class targets
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 38/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- build-system, testing
調査の方向性
Start by reading the existing android_local_test and kt_android_library interfaces referenced in the issue, along with the inline macro example. Determine where a reusable Bazel macro fits in rules_android and how it should handle source discovery and target generation. Done means the supported inputs and generated per-class or per-file targets are defined and covered by tests.
索引モデルが issue の本文から書いたものです。
説明
Hello!
I'm working with rules_android and rules_kotlin together and trying to automate discovery of test files.
Unfortunately, the existing rules only let me add a single test file at a time, which doesn't scale well.
Posted it here first, https://github.com/bazel-contrib/rules_kotlin/issues/1810, but decided to move this discussion to rules_android as it looks to me like Android-specific behavior.
I'm looking for a reusable Bazel macro/rule for Android/Kotlin/Robolectric tests that takes a glob of test files, scans them, and generates one target per test class (or per file) instead of one monolithic android_local_test target.
The patterns I found for doing this:
-
A single
@RunWith(Suite::class)or monolithicandroid_local_testtarget forces everything through one JVM
this kills parallelism, increases Robolectric memory use, and destroys caching -
A custom macro that collects file and generates targets
While the custom macro is probably the structurally correct Bazel solution, it's awkward to write it in every project from scratch. Is there any possibility to add it as a reusable rule?
The macro I'm using:
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_android//rules:rules.bzl", "android_local_test")
load("@rules_kotlin//kotlin:android.bzl", "kt_android_library")
def granular_android_test_suite(
name,
srcs,
custom_package,
manifest,
deps = [],
associates = [],
tags = [],
visibility = None):
test_targets = []
for src in srcs:
base_name = paths.split_extension(paths.basename(src))[0]
# Automatically extracts the package root whether it uses /java/ or /kotlin/
path_segments = src.split("/")
root_index = -1
for root in ["kotlin", "java"]:
if root in path_segments:
root_index = path_segments.index(root) + 1
break
if root_index == -1:
fail("Source file {} must reside under a standard 'java' or 'kotlin' directory.".format(src))
# Reconstruct the package layout into standard dot notation
package_segments = path_segments[root_index:-1]
package_segments.append(base_name)
test_class = ".".join(package_segments)
lib_target_name = "{}_{}_lib".format(name, base_name)
test_target_name = "{}_{}".format(name, base_name)
kt_android_library(
name = lib_target_name,
srcs = [src],
custom_package = custom_package,
manifest = manifest,
associates = associates,
deps = deps,
visibility = ["//visibility:private"],
tags = tags,
)
android_local_test(
name = test_target_name,
test_class = test_class,
manifest = manifest,
custom_package = custom_package,
tags = tags,
visibility = visibility,
deps = [
":" + lib_target_name,
"@rules_robolectric//bazel:android-all",
],
)
test_targets.append(":" + test_target_name)
native.test_suite(
name = name,
tests = test_targets,
tags = tags,
visibility = visibility,
)
Related:
- 主要言語
- Java
- スター
- 205
- フォーク
- 113
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bazelbuild/rules_android のほかの issue
-
build_java8_legacy_dex.sh does not set JAVA_RUNFILES for the d8/r8 launchers対応中かも @TrapsterDK が 17 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
bazelbuild/rules_android#599 ·
メンテナーはふだん 6 日以内に返信
-
`Desugar` actions don't run on multiplex workers対応中かも @lukaciko が 46 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bazelbuild/rules_android#539 · コメント 2 件 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bazelbuild/rules_android#535 · リアクション 2 件 ·
メンテナーはふだん 6 日以内に返信
-
desugar_globals output is not reproducible (zip entry order varies)対応中かも @TrapsterDK が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
bazelbuild/rules_android#610 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
bazelbuild/rules_android#602 ·
メンテナーはふだん 6 日以内に返信
bazelbuild/rules_android の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Lincoln-cn/JAiRouter#1473 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
tetsuji16/microProject#1893 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
liberation-data/fornax4j#325 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwards対応中かも @chonkzillaofficial が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
BCCE-team/BuildCraft#85 ·