本文へ移動
cccskills
無料GitHub で公開日本語紹介

bazel-test-migration

IntelliJのJPSテストモジュールをBazelへ移行し、Bazelだけで起きる失敗を依存関係や実行環境から切り分ける手順を案内します。

原文原文の説明を見る

Migrate IntelliJ JPS module tests to Bazel; debug Bazel-only failures.

JetBrains/intellij-communityスター 20,664(GitHub 20,664 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • JPSテストをBazelへ移行したいとき
  • Bazelだけで起きるテスト失敗を調べたいとき
  • テストの依存関係やデータ設定を確認したいとき

日本語での紹介

できること

IntelliJのJPSテストモジュールをBazelで実行できるように移行する際の手順と、Bazel環境だけで起きる失敗の調査方法をまとめています。まず実際のテストモジュールとBazelラベルを特定し、.imlを依存関係の基準として変更したうえで、生成されたBUILD.bazelを再生成・確認します。コンパイル時の依存不足、実行時に見つからないクラスやリソース、プラグイン登録、テストデータ、runfilesの問題など、症状ごとの確認先と修正方針を示します。JPSとBazelの違いや、TeamCityでの遅延・タイムアウトの切り分けも扱います。テストの除外やアサーション変更で失敗を隠さず、対象を絞った実行から移行先全体の検証へ進む流れを確認できます。

こんなときに便利

既存のJPSテストをBazelへ移したいときや、Bazelでのみテストが失敗して原因を絞れないときに向いています。依存関係やプラグイン、テストデータの設定を見直し、移行が完了したか確認する際にも使えます。

使い方の例

  • 「このJPSテストモジュールをBazelへ移行する手順を整理して」
  • 「Bazelでだけ失敗するテストの依存関係を調べて」
  • 「この移行先ターゲットが完了条件を満たすか確認して」

注意点

記載の移行・検証手順にはBazelコマンドやリポジトリ内のビルドスクリプトが必要です。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md7.2 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/bazel-test-migration/SKILL.md -->

Bazel Test Migration

Use this skill when switching an IntelliJ JPS test module to Bazel, fixing a Bazel-only test failure, or reviewing migration wiring.

Core Workflow

  1. Identify the real test module and Bazel label.

    • From the Ultimate root, community packages usually need @community//....
    • From a standalone community checkout, use //....
    • Do not assume the unqualified label is equivalent in both repositories.
  2. Treat .iml as the source of truth.

    • Add module dependencies to the test module .iml first.
    • Prefer scope="TEST" for new test-only dependencies.
    • Use RUNTIME only when the dependency must be present as a runtime plugin/resource/classpath entry and TEST is not enough.
    • Do not hand-maintain generated BUILD.bazel sections except for intentionally custom jps_test sections protected by ### skip generation section.
  3. Regenerate after every .iml or BUILD.bazel metadata change.

community/tools/bun.cmd build/jps-module.mjs register path/to/module.iml --fix-iml-eof
./build/jpsModelToBazel.cmd
  1. Verify with the Bazel target the user will run.
./bazel.cmd test --cache_test_results=no @community//path/to/package:target_test

For a community-only module in a standalone community checkout, run the same package as //path/to/package:target_test.

BUILD.bazel Rules

  • Keep custom jps_test sections at the top when a module already needs custom test options.
  • Protect a custom test section with:
### skip generation section `test module.name`
  • Preserve required test attributes such as tags, timeout, env, jvm_flags, and data.
  • Add a module to community/build/bazel-migrated-test-modules.txt only after the target is fully migrated and verified. The community JPS aggregator then skips the module, and tests.cmd refuses it. The file documents its format.
  • Do not use copy_file to patch missing jars or descriptors into runfiles. Prefer normal .iml dependencies, target runtime/data dependencies, or the existing shared mechanism for that class of test.

Dependency Decisions

Use the smallest dependency that matches what failed:

  • Compile error: add a normal module dependency to .iml.
  • Test code compiles but class/resource is absent at runtime: add a TEST-scope dependency if generated Bazel runtime wiring is enough; otherwise use runtime/data wiring in the custom jps_test.
  • Plugin descriptor extension/action/inspection is missing: load the owning plugin or content module, not the implementation class by hand.
  • Product plugin wrapper is required: add the wrapper plugin/module dependency to the test module rather than depending only on its internal content module.
  • Testdata is missing: add the testdata as data or ensure the existing generator includes it; do not rely on source-tree paths under Bazel.

Before changing tests, verify whether the failure is really a test assertion issue or just missing runtime/plugin/testdata wiring.

Common Bazel-Only Failures

No tests found

Check that test classes are in the generated *_test_lib, the Bazel target points to that test library, and the class names match the runner convention. If the module truly has no tests, there may be nothing to migrate.

Missing extension, inspection, action, keymap action, or file type

Search for the extension/action/inspection id and identify the descriptor that registers it. Add the owning plugin/module dependency. Do not manually register production extensions in test setup unless the test is explicitly about a local fake extension.

Example: an action registered into EditorGutterVcsPopupMenu needs the VCS implementation descriptor that owns that group, not just VCS API classes.

Plugin action group is not registered

If plugin A registers an action into a group contributed by plugin/module B, plugin A must depend on B or move the action registration into a B-aware optional/content descriptor. Fix the descriptor dependency when production loading is also inconsistent; fix the test dependency only when the test product intentionally omits an otherwise valid product plugin.

JPS compile-server classpath failure

When integration tests invoke JPS compilation, failures like missing JPS jars or compile-server plugin classpaths usually mean Bazel runfiles cannot resolve a plugin/module path the same way JPS does.

  • Prefer the common Bazel target mapping/runfiles mechanism.
  • Ensure Bazel repo mapping from the parent process is propagated when nested Bazel/JPS logic needs to resolve labels.
  • Do not compare file contents to guess class roots.
  • Do not copy individual plugin jars into runfiles as one-off fixes.

Missing required Bazel properties

If code expects Bazel-only properties such as target mappings or runfiles metadata, pass them through the jps_test target using the established option (jvm_flags, env, or data) and add the backing file to runfiles.

Standalone community differs from Ultimate

Re-check labels, repo mappings, and generated runfiles. A target can pass as @community//... from Ultimate and fail as //... in standalone community if the test relies on parent-repo runfiles or missing repo mapping.

TeamCity-only slowdown or timeout

Look for the first expensive operation under Bazel: indexing, plugin loading, coroutine dispatch, first service initialization, or filesystem/runfiles traversal. Prefer moving one-time initialization to setup or making the test wait for the actual condition. Avoid raising timeouts as the first fix.

Test Changes

Keep test edits minimal.

  • Prefer dependency/plugin/testdata wiring over changing assertions.
  • Do not add filters or exclusions to hide failures during migration.
  • Use assumptions only for genuine environment-gated tests, and pass required environment variables through Bazel so developers can still run the tests without editing BUILD.bazel.
  • Avoid moving test classes between modules to satisfy Bazel discovery; fix dependencies or target roots instead.
  • Avoid broad helper abstractions unless the same migration problem repeats across modules and there is already an established local pattern.

Debugging Checklist

  1. Read the failing idea.log, test.log, and JUnit XML if present.
  2. Search for the missing id/class/resource in descriptors and .iml files.
  3. Inspect the test target's generated runtime_deps, deps, data, env, and jvm_flags.
  4. Compare JPS and Bazel classpaths only to identify missing ownership; fix ownership in .iml or plugin descriptors.
  5. Run the smallest failing class or method with --cache_test_results=no.
  6. Run the whole migrated target after the focused failure passes.
  7. Run git diff --check before finishing.

Migration Completion

A module is migrated only when:

  • the correct Bazel target runs with --cache_test_results=no;
  • required plugin/runtime/testdata dependencies are declared normally;
  • generated BUILD.bazel matches .iml;
  • no migration-only test exclusions were added;
  • aggregator lists are updated when required;
  • known unrelated broken tests are documented explicitly in the final report.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

actions

無料概要あり

IntelliJプラグインのAnActionと登録設定を実装・変更し、表示文言やアイコンの定義、非同期処理の起動方法を整えます。

  • IDEに新しいアクションを追加したいとき
  • アクションの登録やアイコンを変更したいとき
  • 表示名と説明文の定義を整理したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

code-style

無料概要あり

IntelliJのKotlin・Javaコードを新規作成やレビューする際に、言語の選び方、書式、型の扱い、例外処理などのプロジェクト規約に沿って整えるスキルです。

  • IntelliJ規約に沿ってKotlinを書きたいとき
  • Javaコードをレビューしたいとき
  • 例外処理やsealed型の分岐を確認したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

commits

無料概要あり

IntelliJ向けの変更を適切な単位に分け、チケットの有無に応じた形式で、理由や判断も伝わるコミットメッセージを作成・修正するスキルです。

  • チケット付き変更のメッセージを作りたいとき
  • テストやドキュメントのコミットを整理したいとき
  • 既存のコミットメッセージを修正したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

compare-python-typecheckers

無料概要あり

Pythonコードの型推論や型エラーを複数の型チェッカーで比較し、各ツールの判定と診断内容をまとめたレポートを作成します。

  • 型推論の違いを比較したいとき
  • 型エラーになるか確かめたいとき
  • 複数チェッカーの診断を見比べたいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

compose-ui-architecture

無料概要あり

Compose Desktopの画面で状態や副作用をどこに持たせるか整理し、表示と判断の境界、再利用部品やリストの設計を整えます。

  • 画面とプレゼンターの責務を分けたいとき
  • UI状態の置き場所を整理したいとき
  • Effectやコルーチンの使い方を見直したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

compose-ui-audit

無料概要あり

Compose DesktopのUIコードを読み、状態管理、画面構成、副作用、コルーチン、再描画の性能など、設計と実行時の問題を具体例とともに監査するスキルです。

  • Compose画面の状態管理を監査したいとき
  • 副作用やコルーチンの使い方を点検したいとき
  • 再描画や遅延リストの性能を調べたいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

JetBrains のスキルをすべて見る

このスキルの問題を報告する