Agent SkillsDetachHead/rebased › bazel-test-migration

bazel-test-migration

GitHub

指导将 IntelliJ JPS 测试模块迁移至 Bazel,修复仅 Bazel 环境的测试失败,处理依赖配置与构建规则。

.claude/skills/bazel-test-migration/SKILL.md DetachHead/rebased

触发场景

迁移测试到 Bazel 修复 Bazel 特有测试失败

安装

npx skills add DetachHead/rebased --skill bazel-test-migration -g -y
更多选项

非标准路径

npx skills add https://github.com/DetachHead/rebased/tree/master/.claude/skills/bazel-test-migration -g -y

不安装直接使用

npx skills use DetachHead/rebased@bazel-test-migration

指定 Agent (Claude Code)

npx skills add DetachHead/rebased --skill bazel-test-migration -a claude-code -g -y

安装 repo 全部 skill

npx skills add DetachHead/rebased --all -g -y

预览 repo 内 skill

npx skills add DetachHead/rebased --list

SKILL.md

Frontmatter
{
    "name": "bazel-test-migration",
    "description": "Migrate IntelliJ JPS module tests to Bazel; debug Bazel-only failures."
}

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_AGGREGATOR_BAZEL_MIGRATED_MODULES only after the target is fully migrated and verified.
  • 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.

版本历史

  • 2af32ff 当前 2026-09-22 01:04

同 Skill 集合

.agents/skills/actions/SKILL.md
.agents/skills/bazel-test-migration/SKILL.md
.agents/skills/code-style/SKILL.md
.agents/skills/commits/SKILL.md
.agents/skills/compare-python-typecheckers/SKILL.md
.agents/skills/conda-env-tests/SKILL.md
.agents/skills/debugging/SKILL.md
.agents/skills/driver-ui-tests/SKILL.md
.agents/skills/eel/SKILL.md
.agents/skills/extract-module/SKILL.md
.agents/skills/fix-project-leak-from-tc-report/SKILL.md
.agents/skills/icon-resources/SKILL.md
.agents/skills/icons/SKILL.md
.agents/skills/ide-diagnostics-mcp/SKILL.md
.agents/skills/jewel-markdown/SKILL.md
.agents/skills/jewel-pr-preparer/SKILL.md
.agents/skills/jewel-release-helper/SKILL.md
.agents/skills/jna/SKILL.md
.agents/skills/kotlin-ui-dsl/SKILL.md
.agents/skills/kotlin-ui-swing-component-architecture/SKILL.md
.agents/skills/module-dependencies/SKILL.md
.agents/skills/module-set-pluginization/SKILL.md
.agents/skills/notebook-for-experiment/SKILL.md
.agents/skills/platform-coroutines-structured-concurrency/SKILL.md
.agents/skills/plugin-model-analyzer/SKILL.md
.agents/skills/poly-context/SKILL.md
.agents/skills/poly-symbols/SKILL.md
.agents/skills/pseudo-kmp/SKILL.md
.agents/skills/registry/SKILL.md
.agents/skills/remote-dev/SKILL.md
.agents/skills/safe-push/SKILL.md
.agents/skills/ssr/SKILL.md
.agents/skills/symbols-api/SKILL.md
.agents/skills/testing-internals/SKILL.md
.agents/skills/testing/SKILL.md
.agents/skills/treehouse/SKILL.md
.agents/skills/ui-accessibility/SKILL.md
.agents/skills/writing-tests/SKILL.md
.agents/skills/youtrack-community/SKILL.md
.claude/skills/actions/SKILL.md
.claude/skills/code-style/SKILL.md
.claude/skills/commits/SKILL.md
.claude/skills/compare-python-typecheckers/SKILL.md
.claude/skills/conda-env-tests/SKILL.md
.claude/skills/debugging/SKILL.md
.claude/skills/driver-ui-tests/SKILL.md
.claude/skills/eel/SKILL.md
.claude/skills/extract-module/SKILL.md
.claude/skills/fix-project-leak-from-tc-report/SKILL.md

元信息

文件数
0
版本
2af32ff
Hash
f0bea9e6
收录时间
2026-09-22 01:04

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-22 10:54
浙ICP备14020137号-1