blob: 33bef08aa2478eb8d289541354f6117561f9c480 [file] [log] [blame]
vasilvv0604a532022-05-24 12:59:16 -07001"""Tools for building QUICHE tests."""
2
vasilvv4a0a1522022-09-26 13:12:57 -07003load("@bazel_skylib//lib:dicts.bzl", "dicts")
vasilvv0604a532022-05-24 12:59:16 -07004load("@bazel_skylib//lib:paths.bzl", "paths")
5
6def test_suite_from_source_list(name, srcs, **kwargs):
7 """
8 Generates a test target for every individual test source file specified.
9
10 Args:
11 name: the name of the resulting test_suite target.
12 srcs: the list of source files from which the test targets are generated.
13 **kwargs: other arguments that are passed to the cc_test rule directly.s
14 """
15
16 tests = []
17 for sourcefile in srcs:
18 if not sourcefile.endswith("_test.cc"):
19 fail("All source files passed to test_suite_from_source_list() must end with _test.cc")
20 test_name, _ = paths.split_extension(paths.basename(sourcefile))
vasilvv4a0a1522022-09-26 13:12:57 -070021 extra_kwargs = {}
22 if test_name == "end_to_end_test":
23 extra_kwargs["shard_count"] = 16
vasilvv0604a532022-05-24 12:59:16 -070024 native.cc_test(
25 name = test_name,
26 srcs = [sourcefile],
vasilvv4a0a1522022-09-26 13:12:57 -070027 **dicts.add(kwargs, extra_kwargs)
vasilvv0604a532022-05-24 12:59:16 -070028 )
29 tests.append(test_name)
30 native.test_suite(name = name, tests = tests)