Skip to content

go: keep internal Test Optimization helpers manual - #267

Merged
tonyredondo merged 1 commit into
mainfrom
fix/manual-go-helper-targets
Sep 22, 2026
Merged

tonyredondo merged 1 commit into
mainfrom
fix/manual-go-helper-targets

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

Summary

dd_topt_go_test generates two implementation-only targets for every optimized Go test: the payload selector and the Bazel metadata writer. This change marks both helpers manual, so recursive build and test patterns do not select them as independent top-level targets.

The public Go test still depends on both helpers, so explicitly selected .topt tests keep the same payload selection, metadata generation, instrumentation, and upload behavior.

Why

A consumer can declare static Test Optimization targets while keeping Test Optimization disabled for an ordinary Bazel invocation. Recursive target patterns should select the public tests, not their internal payload and metadata rules. Selecting an internal helper directly can force Bazel to analyze a disabled Test Optimization repository even though no optimized test was requested.

The strict repository-state validation remains unchanged when a helper or .topt target is selected explicitly. manual affects wildcard build/test expansion; it does not hide targets from query or cquery. Consumer-side declaration gating is therefore a separate follow-up where cquery must avoid disabled .topt targets entirely.

Regression coverage

The new loading-phase suite inspects the rules generated by the real macro and verifies:

  • dynamic payload helpers are manual
  • dynamic metadata helpers are manual
  • static payload helpers are manual
  • static metadata helpers are manual
  • disabled generated exports still omit payload helpers
  • disabled generated exports still omit metadata helpers

Validation

  • ./bazelw test //modules/go/tests:go_macro_internal_helper_tags_tests --noexperimental_split_xml_generation --test_output=errors --noshow_progress
  • cd modules/go && ../../bazelw test //... --override_module=datadog-rules-test-optimization=../.. --noexperimental_split_xml_generation --nocache_test_results --test_output=errors --noshow_progress (101 tests passed)
  • ./bazelw test //... --java_runtime_version=remotejdk_21 --tool_java_runtime_version=remotejdk_21 --noexperimental_split_xml_generation --test_env=PYTHON=/opt/homebrew/bin/python3.14 --test_output=errors --noshow_progress (511 tests passed)
  • PYTHON=/opt/homebrew/bin/python3.14 USE_BAZEL_VERSION=8.5.1 tools/tests/integration/run_mock_server_tests.sh
  • consumer query of the four generated dynamic/static helpers confirmed tags = ["manual"]
  • buildifier -mode=check modules/go/topt_go_test.bzl modules/go/tests/test_macro.bzl modules/go/tests/BUILD.bazel
  • git diff --check

@tonyredondo
tonyredondo requested a review from a team as a code owner September 22, 2026 13:58

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The Go macro now marks both generated helper targets as manual. The static review found no concrete failure mode in helper wiring or the new loading-phase coverage.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 5f2da94 · @DataDog review to ask questions

@tonyredondo
tonyredondo merged commit 474a950 into main Sep 22, 2026
62 checks passed
@tonyredondo
tonyredondo deleted the fix/manual-go-helper-targets branch September 22, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants