Skip to content
Closed
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
8 changes: 5 additions & 3 deletions lib/test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Aggregates multiple Starlark tests in a single test_suite.
load("//lib:unit_test.bzl", "unit_test")
load("//lib/private:util.bzl", "get_test_name_from_function")

def test_suite(name, *, tests = [], basic_tests = [], test_kwargs = {}):
def test_suite(name, *, tests = [], basic_tests = [], test_kwargs = {}, test_name_resolver = get_test_name_from_function):
"""Instantiates given test macros/implementations and gathers their main targets into a `test_suite`.

Use this function to wrap all tests into a single target.
Expand Down Expand Up @@ -45,16 +45,18 @@ def test_suite(name, *, tests = [], basic_tests = [], test_kwargs = {}):
become the name of the test.
test_kwargs: (dict) Additional kwargs to pass onto each test (both
regular and basic test callables).
test_name_resolver: (callable) A function to map test function to the
test name.
"""
test_targets = []

for setup_func in tests:
test_name = get_test_name_from_function(setup_func)
test_name = test_name_resolver(setup_func)
setup_func(name = test_name, **test_kwargs)
test_targets.append(test_name)

for impl in basic_tests:
test_name = get_test_name_from_function(impl)
test_name = test_name_resolver(impl)
unit_test(name = test_name, impl = impl, **test_kwargs)
test_targets.append(test_name)

Expand Down