Skip to content

Commit a82a131

Browse files
committed
loadingtests: add default timeout
loadingtests didn't provide a way to set a timeout, which means they trip --test_verbose_timeout_warnings; this provides a basic way to do so, and sets a default timeout of short since normal loadingtests would have a hard time successfully being any larger.
1 parent 454b259 commit a82a131

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/unittest_doc.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ Asserts that the given `condition` is true.
396396
<pre>
397397
load("@bazel_skylib//lib:unittest.bzl", "loadingtest")
398398

399-
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>)
399+
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>)
400400
</pre>
401401

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

414415
**RETURNS**
415416

lib/unittest.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,15 @@ def _loading_make(name):
640640
)
641641
return struct(name = name)
642642

643-
def _loading_assert_equals(env, test_case, expected, actual):
643+
def _loading_assert_equals(env, test_case, expected, actual, timeout = "short"):
644644
"""Creates a test case for asserting state at LOADING phase.
645645
646646
Args:
647647
env: Loading test env created from loadingtest.make
648648
test_case: Name of the test case
649649
expected: Expected value to test
650650
actual: Actual value received.
651+
timeout: Test timeout passed into the generated rule.
651652
652653
Returns:
653654
None, creates test case
@@ -661,6 +662,7 @@ def _loading_assert_equals(env, test_case, expected, actual):
661662
name = "%s_%s" % (env.name, test_case),
662663
failure_message = msg,
663664
tags = [env.name + "_test_case"],
665+
timeout = timeout,
664666
)
665667

666668
asserts = struct(

0 commit comments

Comments
 (0)