xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/whl_filegroup/whl_filegroup_tests.bzl (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1"""Test for py_wheel."""
2
3load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
4load("@rules_testing//lib:util.bzl", "util")
5load("//python:pip.bzl", "whl_filegroup")
6
7def _test_runfiles(name):
8    for runfiles in [True, False]:
9        util.helper_target(
10            whl_filegroup,
11            name = name + "_subject_runfiles_{}".format(runfiles),
12            whl = ":wheel",
13            runfiles = runfiles,
14        )
15    analysis_test(
16        name = name,
17        impl = _test_runfiles_impl,
18        targets = {
19            "no_runfiles": name + "_subject_runfiles_False",
20            "with_runfiles": name + "_subject_runfiles_True",
21        },
22    )
23
24def _test_runfiles_impl(env, targets):
25    env.expect.that_target(targets.with_runfiles).runfiles().contains_exactly([env.ctx.workspace_name + "/{package}/{name}"])
26    env.expect.that_target(targets.no_runfiles).runfiles().contains_exactly([])
27
28def whl_filegroup_test_suite(name):
29    """Create the test suite.
30
31    Args:
32        name: the name of the test suite
33    """
34    test_suite(name = name, tests = [_test_runfiles])
35