Fix doc error for analystest.begin (#369)

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
This commit is contained in:
Vinh Tran 2022-08-25 17:47:50 -04:00 committed by GitHub
parent c1dfc324fb
commit 69b4636956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -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.

View File

@ -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,