diff options
author | Vinh Tran <daivinhtran.vt@gmail.com> | 2022-08-25 17:47:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 17:47:50 -0400 |
commit | 69b4636956c55b620c0776f4262a38a15554169c (patch) | |
tree | 2ed8a633e1b6e0d5cba5ce1f7536bcd07b4a0c69 /lib | |
parent | c1dfc324fbac0d5e4da32a93a3cafb2dc8908a09 (diff) | |
download | bazel-skylib-69b4636956c55b620c0776f4262a38a15554169c.tar.gz |
Fix doc error for analystest.begin (#369)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/unittest.bzl | 21 |
1 files changed, 20 insertions, 1 deletions
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, |