Add bazel support for doc unit tests - 1#9385
Add bazel support for doc unit tests - 1#9385luarss wants to merge 2 commits intoThe-OpenROAD-Project:masterfrom
Conversation
- 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>
|
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
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.
src/cts/test/BUILD
Outdated
| "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", | ||
| ], |
There was a problem hiding this comment.
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.
b2f93c5 to
f8cb177
Compare
|
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>
f8cb177 to
3a2da84
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
Part 1
openroad -pythonpath by using bazel'spy_testexecutable. which works because we do not need any external libs, just pystd will do.doc_test_utilsfilegroup exporting shared py test scriptsstandalone_pythoninstantiationreadme_msgs_check, pending fix