Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc param to unittest.make #464

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/unittest_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Registers the toolchains for unittest users.
## unittest.make

<pre>
unittest.make(<a href="#unittest.make-impl">impl</a>, <a href="#unittest.make-attrs">attrs</a>)
unittest.make(<a href="#unittest.make-impl">impl</a>, <a href="#unittest.make-attrs">attrs</a>, <a href="#unittest.make-doc">doc</a>)
</pre>

Creates a unit test rule from its implementation function.
Expand Down Expand Up @@ -462,6 +462,7 @@ Recall that names of test rules must end in `_test`.
| :------------- | :------------- | :------------- |
| <a id="unittest.make-impl"></a>impl | The implementation function of the unit test. | none |
| <a id="unittest.make-attrs"></a>attrs | An optional dictionary to supplement the attrs passed to the unit test's <code>rule()</code> constructor. | <code>{}</code> |
| <a id="unittest.make-doc"></a>doc | A description of the rule that can be extracted by documentation generating tools. | <code>""</code> |

**RETURNS**

Expand Down
4 changes: 3 additions & 1 deletion lib/unittest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _impl_function_name(impl):
impl_name = impl_name.partition("<function ")[-1]
return impl_name.rpartition(">")[0]

def _make(impl, attrs = {}):
def _make(impl, attrs = {}, doc = ""):
"""Creates a unit test rule from its implementation function.

Each unit test is defined in an implementation function that must then be
Expand Down Expand Up @@ -178,6 +178,7 @@ def _make(impl, attrs = {}):
impl: The implementation function of the unit test.
attrs: An optional dictionary to supplement the attrs passed to the
unit test's `rule()` constructor.
doc: A description of the rule that can be extracted by documentation generating tools.

Returns:
A rule definition that should be stored in a global whose name ends in
Expand All @@ -188,6 +189,7 @@ def _make(impl, attrs = {}):

return rule(
impl,
doc = doc,
attrs = attrs,
_skylark_testable = True,
test = True,
Expand Down