aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinh Tran <daivinhtran.vt@gmail.com>2022-08-25 17:47:50 -0400
committerGitHub <noreply@github.com>2022-08-25 17:47:50 -0400
commit69b4636956c55b620c0776f4262a38a15554169c (patch)
tree2ed8a633e1b6e0d5cba5ce1f7536bcd07b4a0c69
parentc1dfc324fbac0d5e4da32a93a3cafb2dc8908a09 (diff)
downloadbazel-skylib-69b4636956c55b620c0776f4262a38a15554169c.tar.gz
Fix doc error for analystest.begin (#369)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
-rwxr-xr-xdocs/unittest_doc.md6
-rw-r--r--lib/unittest.bzl21
2 files changed, 23 insertions, 4 deletions
diff --git a/docs/unittest_doc.md b/docs/unittest_doc.md
index 5472d74..facd55f 100755
--- a/docs/unittest_doc.md
+++ b/docs/unittest_doc.md
@@ -94,9 +94,9 @@ A rule definition that should be stored in a global whose name ends in
analysistest.begin(<a href="#analysistest.begin-ctx">ctx</a>)
</pre>
-Begins a unit test.
+Begins an analysis test.
-This should be the first function called in a unit test implementation
+This should be the first function called in an analysis test implementation
function. It initializes a "test environment" that is used to collect
assertion failures so that they can be reported and logged at the end of the
test.
@@ -112,7 +112,7 @@ test.
**RETURNS**
A test environment struct that must be passed to assertions and finally to
-`unittest.end`. Do not rely on internal details about the fields in this
+`analysistest.end`. Do not rely on internal details about the fields in this
struct as it may change.
diff --git a/lib/unittest.bzl b/lib/unittest.bzl
index 3757b08..badb462 100644
--- a/lib/unittest.bzl
+++ b/lib/unittest.bzl
@@ -364,6 +364,25 @@ def _begin(ctx):
"""
return struct(ctx = ctx, failures = [])
+def _begin_analysis_test(ctx):
+ """Begins an analysis test.
+
+ This should be the first function called in an analysis test implementation
+ function. It initializes a "test environment" that is used to collect
+ assertion failures so that they can be reported and logged at the end of the
+ test.
+
+ Args:
+ ctx: The Starlark context. Pass the implementation function's `ctx` argument
+ in verbatim.
+
+ Returns:
+ A test environment struct that must be passed to assertions and finally to
+ `analysistest.end`. Do not rely on internal details about the fields in this
+ struct as it may change.
+ """
+ return struct(ctx = ctx, failures = [])
+
def _end_analysis_test(env):
"""Ends an analysis test and logs the results.
@@ -647,7 +666,7 @@ unittest = struct(
analysistest = struct(
make = _make_analysis_test,
- begin = _begin,
+ begin = _begin_analysis_test,
end = _end_analysis_test,
fail = _fail,
target_actions = _target_actions,