aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUebelAndre <github@uebelandre.com>2023-10-31 00:52:17 -0700
committerGitHub <noreply@github.com>2023-10-31 08:52:17 +0100
commitd77c6fbaf7526ceeb7a6bb1fdbefc113bb0e06a1 (patch)
tree531721508e5e85a50188bdf21a18f7e7cf6fc73f
parent8da4759611fd953945540c78c59da99869d239ce (diff)
downloadbazel-skylib-d77c6fbaf7526ceeb7a6bb1fdbefc113bb0e06a1.tar.gz
Add `doc` param to `unittest.make` (#464)
-rwxr-xr-xdocs/unittest_doc.md3
-rw-r--r--lib/unittest.bzl4
2 files changed, 5 insertions, 2 deletions
diff --git a/docs/unittest_doc.md b/docs/unittest_doc.md
index a13b32a..353d05b 100755
--- a/docs/unittest_doc.md
+++ b/docs/unittest_doc.md
@@ -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.
@@ -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**
diff --git a/lib/unittest.bzl b/lib/unittest.bzl
index 4398f16..02e374c 100644
--- a/lib/unittest.bzl
+++ b/lib/unittest.bzl
@@ -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
@@ -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
@@ -188,6 +189,7 @@ def _make(impl, attrs = {}):
return rule(
impl,
+ doc = doc,
attrs = attrs,
_skylark_testable = True,
test = True,