Skip to content

Comments

Add bazel support for doc unit tests - 1#9385

Open
luarss wants to merge 2 commits intoThe-OpenROAD-Project:masterfrom
luarss:topic/bazel-doctests-1
Open

Add bazel support for doc unit tests - 1#9385
luarss wants to merge 2 commits intoThe-OpenROAD-Project:masterfrom
luarss:topic/bazel-doctests-1

Conversation

@luarss
Copy link
Contributor

@luarss luarss commented Jan 29, 2026

Part 1

  • core idea is to override the broken openroad -python path by using bazel's py_test executable. which works because we do not need any external libs, just pystd will do.
  • create shared doc_test_utils filegroup exporting shared py test scripts
  • add exports on README to accessible to test targets
  • use native py_test for standalone_python
  • filegroup -> py_library for shared scripts
  • centralize deps on standalone_python instantiation
  • disable readme_msgs_check, pending fix

- create shared `doc_test_utils` filegroup exporting shared py test scripts
- add exports on README to accessible to test targets

Signed-off-by: Jack Luar <39641663+luarss@users.noreply.github.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds Bazel support for documentation unit tests by introducing a standalone_python test type that leverages native.py_test. The changes are well-structured, including a new py_library for shared test utilities and correctly exporting README.md files as test data. The implementation is consistent across the various modules.

I have two main suggestions for improvement. First, there's a redundant dependency declaration for doc_test_utils in the test data, which should be removed as it's already handled in deps. Second, there's significant code duplication in the test/BUILD files for defining documentation test resources, and I've recommended a refactoring to improve maintainability. These points are detailed in the specific comments.

Comment on lines 213 to 220
"cts_man_tcl_check": [
"//docs/src/scripts:doc_test_utils",
"//src/cts:README.md",
],
"cts_readme_msgs_check": [
"//docs/src/scripts:doc_test_utils",
"//src/cts:README.md",
],
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This block of code for ..._man_tcl_check and ..._readme_msgs_check is duplicated across many test/BUILD files (e.g., for ant, dft, dpl, etc.), with only the module name changing. This harms maintainability as any change to this structure needs to be applied in many places.

To improve this, you could abstract this logic into a helper function in a shared .bzl file (e.g., test/regression.bzl) and call it from each BUILD file. The refactoring in src/mpl/test/BUILD is a good first step in this direction.

Example helper function (assuming the redundant doc_test_utils dependency is removed as per my other comment):

def doc_test_resources(module_name):
    """Returns a dictionary of resources for documentation tests."""
    return {
        module_name + "_man_tcl_check": [
            "//src/" + module_name + ":README.md",
        ],
        module_name + "_readme_msgs_check": [
            "//src/" + module_name + ":README.md",
        ],
    }

Using this helper would centralize the logic and make the build configuration cleaner. This could be addressed in a follow-up PR.

@luarss luarss force-pushed the topic/bazel-doctests-1 branch from b2f93c5 to f8cb177 Compare January 29, 2026 09:06
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

- use native py_test for standalone_python
- filegroup -> py_library for shared scripts
- centralize deps on `standalone_python` instantiation
- remove duplicate doc_util invocation in test/BUILD
- disable `readme_msgs_check`, pending fix

Signed-off-by: Jack Luar <39641663+luarss@users.noreply.github.com>
@luarss luarss force-pushed the topic/bazel-doctests-1 branch from f8cb177 to 3a2da84 Compare January 29, 2026 09:11
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@luarss luarss requested a review from maliberty January 30, 2026 07:24
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.

1 participant