Skip to content
Open
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 @@ -396,7 +396,7 @@ Asserts that the given `condition` is true.
<pre>
load("@bazel_skylib//lib:unittest.bzl", "loadingtest")

loadingtest.equals(<a href="#loadingtest.equals-env">env</a>, <a href="#loadingtest.equals-test_case">test_case</a>, <a href="#loadingtest.equals-expected">expected</a>, <a href="#loadingtest.equals-actual">actual</a>)
loadingtest.equals(<a href="#loadingtest.equals-env">env</a>, <a href="#loadingtest.equals-test_case">test_case</a>, <a href="#loadingtest.equals-expected">expected</a>, <a href="#loadingtest.equals-actual">actual</a>, <a href="#loadingtest.equals-timeout">timeout</a>)
</pre>

Creates a test case for asserting state at LOADING phase.
Expand All @@ -410,6 +410,7 @@ Creates a test case for asserting state at LOADING phase.
| <a id="loadingtest.equals-test_case"></a>test_case | Name of the test case | none |
| <a id="loadingtest.equals-expected"></a>expected | Expected value to test | none |
| <a id="loadingtest.equals-actual"></a>actual | Actual value received. | none |
| <a id="loadingtest.equals-timeout"></a>timeout | Test timeout passed into the generated rule. | `"short"` |

**RETURNS**

Expand Down
4 changes: 3 additions & 1 deletion lib/unittest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,15 @@ def _loading_make(name):
)
return struct(name = name)

def _loading_assert_equals(env, test_case, expected, actual):
def _loading_assert_equals(env, test_case, expected, actual, timeout = "short"):
"""Creates a test case for asserting state at LOADING phase.

Args:
env: Loading test env created from loadingtest.make
test_case: Name of the test case
expected: Expected value to test
actual: Actual value received.
timeout: Test timeout passed into the generated rule.

Returns:
None, creates test case
Expand All @@ -661,6 +662,7 @@ def _loading_assert_equals(env, test_case, expected, actual):
name = "%s_%s" % (env.name, test_case),
failure_message = msg,
tags = [env.name + "_test_case"],
timeout = timeout,
)

asserts = struct(
Expand Down