1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@rules_python//python:defs.bzl", "py_binary")
16load("//build/bazel/rules/tradefed:tradefed.bzl", "TEST_DEP_SUFFIX", "tradefed_test_suite")
17
18def py_test(
19        name = "",
20        deps = [],
21        srcs = [],
22        main = None,
23        tags = [],
24        test_config = None,
25        template_test_config = None,
26        template_configs = [],
27        template_install_base = None,
28        visibility = None,
29        target_compatible_with = [],
30        **kwargs):
31    test_dep_name = name + TEST_DEP_SUFFIX
32
33    py_binary(
34        name = test_dep_name,
35        deps = deps,
36        srcs = srcs,
37        main = main or "%s.py" % name,
38        tags = tags + ["manual"],
39        visibility = visibility,
40        target_compatible_with = target_compatible_with,
41        **kwargs
42    )
43
44    tradefed_test_suite(
45        name = name,
46        test_dep = test_dep_name,
47        test_config = test_config,
48        template_test_config = template_test_config,
49        template_configs = template_configs,
50        template_install_base = template_install_base,
51        deviceless_test_config = "//build/make/core:python_binary_host_test_config_template.xml",
52        tags = tags,
53        visibility = visibility,
54    )
55