Bazel Macros and Rules#
ITF provides two public Bazel build definitions: the py_itf_test macro
for declaring test targets and the py_itf_plugin rule for declaring
plugin targets.
py_itf_test#
Defined in //bazel:py_itf_test.bzl. Declare with:
load("@score_itf//:defs.bzl", "py_itf_test")
Minimal example:
py_itf_test(
name = "test_example",
srcs = ["test_example.py"],
args = ["--docker-image=ubuntu:24.04"],
plugins = ["@score_itf//score/itf/plugins:docker_plugin"],
)
Attributes#
Attribute |
Type |
Default |
Description |
|---|---|---|---|
|
label list |
mandatory |
Test source files ( |
|
label list |
|
List of |
|
string list |
|
Extra CLI arguments passed to pytest. Supports
|
|
label list |
|
Data files built for target configuration (e.g. QEMU images,
config files). |
|
label list |
|
Data files built for the exec (host) configuration. |
|
label list |
|
Additional Python dependencies for the test binary. |
|
label |
|
Custom pytest configuration file. If omitted, the default
|
|
string dict |
|
Additional environment variables set for the test process.
|
|
string list |
|
Standard Bazel test tags (e.g. |
|
string |
|
Standard Bazel test timeout ( |
|
string |
|
Standard Bazel test size. |
py_itf_plugin#
Defined in //bazel:py_itf_plugin.bzl. Declare with:
load("@score_itf//bazel:py_itf_plugin.bzl", "py_itf_plugin")
Example — defining a custom plugin:
py_itf_plugin(
name = "my_plugin",
enabled_plugins = ["my_plugin"],
py_library = "//path/to:my_plugin_lib",
visibility = ["//visibility:public"],
)
Attributes#
Attribute |
Type |
Default |
Description |
|---|---|---|---|
|
label |
mandatory |
The |
|
string list |
|
Pytest plugin module paths to activate (passed as |
|
string list |
|
Additional CLI arguments contributed to every test that uses this
plugin. Supports |
|
label list |
|
Data files built for target configuration that are required by the plugin at runtime. |
|
label list |
|
Data files built for exec (host) configuration required by the plugin. |
|
string dict |
|
Environment variables contributed by the plugin to every test that uses it. |