From addf7466285b8d345d4e109a5e3e0b79d8b78fd8 Mon Sep 17 00:00:00 2001 From: Lukasz Tekieli Date: Fri, 27 Feb 2026 14:21:30 +0100 Subject: [PATCH] Support select arguments in py_itf_test --- MODULE.bazel | 1 + bazel/py_itf_plugin.bzl | 92 +++++++++-- bazel/py_itf_test.bzl | 289 ++++++++++++++++++++++++++-------- bazel/rules/BUILD | 12 -- bazel/rules/as_exec.bzl | 44 ------ bazel/rules/run_as_exec.bzl | 104 ------------ examples/examples/itf/BUILD | 15 +- score/itf/plugins/BUILD | 36 +++++ score/itf/plugins/dlt/BUILD | 8 +- score/itf/plugins/plugins.bzl | 61 ------- test/BUILD | 56 +++++-- 11 files changed, 399 insertions(+), 319 deletions(-) delete mode 100644 bazel/rules/BUILD delete mode 100644 bazel/rules/as_exec.bzl delete mode 100644 bazel/rules/run_as_exec.bzl delete mode 100644 score/itf/plugins/plugins.bzl diff --git a/MODULE.bazel b/MODULE.bazel index 7316690..85a246b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -115,6 +115,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0") ############################################################################### bazel_dep(name = "score_tooling", version = "1.0.4") bazel_dep(name = "score_bazel_platforms", version = "0.0.3") +bazel_dep(name = "platforms", version = "1.0.0") ################################################################################ # diff --git a/bazel/py_itf_plugin.bzl b/bazel/py_itf_plugin.bzl index 54136f5..e6b8e06 100644 --- a/bazel/py_itf_plugin.bzl +++ b/bazel/py_itf_plugin.bzl @@ -10,13 +10,87 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +"""Bazel rule for defining ITF test plugins.""" -def py_itf_plugin(py_library, enabled_plugins, args, data, data_as_exec, tags): - return struct( - py_library = py_library, - enabled_plugins = enabled_plugins, - args = args, - data = data, - data_as_exec = data_as_exec, - tags = tags, - ) +load("@rules_python//python:defs.bzl", "PyInfo") + +PyItfPluginInfo = provider( + doc = "Information about an ITF test plugin.", + fields = { + "enabled_plugins": "List of pytest plugin module paths to enable.", + "resolved_args": "List of CLI args with $(location ...) pre-resolved.", + "plugin_runfiles": "Merged runfiles from all plugin data dependencies.", + "plugin_files": "Depset of all files contributed by the plugin.", + }, +) + +def _py_itf_plugin_impl(ctx): + # Resolve $(location ...) in plugin args using the plugin's own data targets. + # Rewrite $(location) → $(rootpath) for runfiles-relative paths. + all_data_targets = list(ctx.attr.plugin_data) + list(ctx.attr.plugin_data_as_exec) + resolved_args = [] + for arg in ctx.attr.plugin_args: + arg = arg.replace("$(location ", "$(rootpath ").replace("$(locations ", "$(rootpaths ") + resolved_args.append(ctx.expand_location(arg, targets = all_data_targets)) + + # Collect all plugin files and runfiles + plugin_file_depsets = [] + plugin_runfiles = ctx.runfiles() + for dep in all_data_targets: + plugin_file_depsets.append(dep[DefaultInfo].files) + if dep[DefaultInfo].default_runfiles: + plugin_runfiles = plugin_runfiles.merge(dep[DefaultInfo].default_runfiles) + + all_plugin_files = depset(transitive = plugin_file_depsets) + plugin_runfiles = plugin_runfiles.merge(ctx.runfiles( + transitive_files = all_plugin_files, + )) + + # Build providers list - always include PyItfPluginInfo + providers = [ + PyItfPluginInfo( + enabled_plugins = ctx.attr.enabled_plugins, + resolved_args = resolved_args, + plugin_runfiles = plugin_runfiles, + plugin_files = all_plugin_files, + ), + ] + + # Forward PyInfo from py_library so this target can be used as a py_test dep + if PyInfo in ctx.attr.py_library: + providers.append(ctx.attr.py_library[PyInfo]) + + # Forward DefaultInfo from py_library (carries runfiles for Python imports) + providers.append(ctx.attr.py_library[DefaultInfo]) + + return providers + +py_itf_plugin = rule( + doc = "Defines an ITF test plugin with its dependencies and configuration.", + implementation = _py_itf_plugin_impl, + attrs = { + "py_library": attr.label( + doc = "The py_library target providing the plugin's Python code.", + mandatory = True, + ), + "enabled_plugins": attr.string_list( + doc = "List of pytest plugin module paths to enable (e.g. 'score.itf.plugins.docker').", + default = [], + ), + "plugin_args": attr.string_list( + doc = "Additional CLI arguments. Supports $(location ...) referencing plugin_data targets.", + default = [], + ), + "plugin_data": attr.label_list( + doc = "Data files built for target configuration.", + default = [], + allow_files = True, + ), + "plugin_data_as_exec": attr.label_list( + doc = "Data files built for exec (host) configuration.", + default = [], + allow_files = True, + cfg = "exec", + ), + }, +) diff --git a/bazel/py_itf_test.bzl b/bazel/py_itf_test.bzl index 292b4a1..0e5be38 100644 --- a/bazel/py_itf_test.bzl +++ b/bazel/py_itf_test.bzl @@ -10,83 +10,244 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -"""Bazel interface for running pytest""" - -load("@rules_python//python:defs.bzl", "py_test") -load("@score_itf//bazel/rules:run_as_exec.bzl", "test_as_exec") - -def py_itf_test(name, srcs, args = [], data = [], data_as_exec = [], plugins = [], deps = [], tags = []): - """Bazel macro for running ITF tests. - - Args: - name: Name of the test target. - srcs: List of source files for the test. - args: Additional arguments to pass to ITF. - data: Data files that will be build for target config. - data_as_exec: Data files that will be build for exec(host) config. - plugins: List of pytest plugins to enable. - deps: Additional python dependencies needed for the test. - tags: Tags forwarded to the test target. - """ - pytest_bootstrap = Label("@score_itf//:main.py") - pytest_ini = Label("@score_itf//:pytest.ini") - plugin_deps = [] - for plugin in plugins: - plugin_deps.append(plugin.py_library) +"""Bazel symbolic macro for running pytest via ITF.""" - plugin_tags = [] - for plugin in plugins: - plugin_tags.extend(plugin.tags) +load("@rules_python//python:defs.bzl", "PyInfo", "py_test") +load("@score_itf//bazel:py_itf_plugin.bzl", "PyItfPluginInfo") - py_test( - name = "_" + name, - srcs = [ - pytest_bootstrap, - ] + srcs, - main = pytest_bootstrap, - deps = [ - # Only core ITF dep allowed, rest is resolved by plugins - "@score_itf//:itf", - ] + deps + plugin_deps, - tags = ["manual"] + tags + plugin_tags, +# ============================================================================= +# Wrapper test rule: resolves plugin providers at analysis time and creates +# a launcher script that invokes the py_test binary with the full arg list. +# ============================================================================= + +def _itf_test_impl(ctx): + executable = ctx.executable.test_binary + pytest_ini = ctx.file.pytest_ini + + # ---- build the full argument list ---- + args = [] + + # 1. User-supplied args (expand $(location ...) against data + data_as_exec) + # Rewrite $(location) → $(rootpath) so expand_location produces + # runfiles-relative paths instead of exec-root-relative paths. + # This matches Bazel's native test-rule args semantics. + expand_targets = list(ctx.attr.data) + list(ctx.attr.data_as_exec) + [ctx.attr.pytest_ini] + for arg in ctx.attr.extra_args: + arg = arg.replace("$(location ", "$(rootpath ").replace("$(locations ", "$(rootpaths ") + args.append(ctx.expand_location(arg, targets = expand_targets)) + + # 2. Pytest configuration + args.extend(["-c", pytest_ini.short_path]) + args.extend(["-p", "no:cacheprovider", "--show-capture=no"]) + + # 3. Plugin enable flags and plugin-specific args (resolved at analysis time) + args.append("-p score.itf.plugins.core") + for plugin_target in ctx.attr.plugins: + info = plugin_target[PyItfPluginInfo] + for ep in info.enabled_plugins: + args.append("-p %s" % ep) + args.extend(info.resolved_args) + + # 4. Source file paths (positional args for pytest) + for src in ctx.files.srcs: + args.append(src.short_path) + + # ---- create symlink to exec-config binary ---- + # The test_binary is built with cfg="exec", so its short_path has ../ + # prefixes. A symlink declared in the main repo has a clean short_path + # that works correctly in the runfiles tree. + inner_bin = ctx.actions.declare_file(ctx.attr.name + ".bin") + ctx.actions.symlink( + output = inner_bin, + target_file = executable, + is_executable = True, ) - plugin_enable_args = ["-p score.itf.plugins.core"] - for plugin in plugins: - for enabled_plugin in plugin.enabled_plugins: - plugin_enable_args.append("-p %s" % enabled_plugin) + # ---- collect plugin Python import paths for PYTHONPATH ---- + # When plugins use select(), the select may resolve to different branches + # for _itf_test (target config) vs py_test (exec config via cfg transition). + # Augmenting PYTHONPATH ensures the correct plugin packages are importable. + plugin_imports = [] + for plugin_target in ctx.attr.plugins: + if PyInfo in plugin_target: + plugin_imports.extend(plugin_target[PyInfo].imports.to_list()) + seen = {} + unique_imports = [] + for imp in plugin_imports: + if imp not in seen: + seen[imp] = True + unique_imports.append(imp) - plugin_args = [] - for plugin in plugins: - plugin_args.extend(plugin.args) + # ---- create launcher script ---- + launcher = ctx.actions.declare_file(ctx.attr.name) + quoted = " ".join(['"%s"' % a.replace("\\", "\\\\").replace('"', '\\"') for a in args]) - plugin_data = [] - for plugin in plugins: - plugin_data.extend(plugin.data) + # Build the launcher line by line using %s to avoid .format() vs shell $ conflicts. + launcher_lines = [ + "#!/bin/bash", + 'RUNFILES_DIR="${RUNFILES_DIR:-$0.runfiles}"', + "export RUNFILES_DIR", + ] + if unique_imports: + pythonpath_entries = ":".join( + ["$RUNFILES_DIR/%s" % imp for imp in unique_imports], + ) + launcher_lines.append( + 'export PYTHONPATH="%s${PYTHONPATH:+:$PYTHONPATH}"' % pythonpath_entries, + ) + launcher_lines.append( + 'exec "$RUNFILES_DIR/%s/%s" %s "$@"' % ( + ctx.workspace_name, + inner_bin.short_path, + quoted, + ), + ) + launcher_lines.append("") # trailing newline - plugin_data_as_exec = [] - for plugin in plugins: - plugin_data_as_exec.extend(plugin.data_as_exec) + ctx.actions.write( + output = launcher, + content = "\n".join(launcher_lines), + is_executable = True, + ) - data_as_exec = [pytest_ini] + srcs + data_as_exec + plugin_data_as_exec + # ---- merge runfiles ---- + direct_files = ( + ctx.files.data + + ctx.files.data_as_exec + + ctx.files.srcs + + [pytest_ini, inner_bin] + + ctx.files.test_binary + ) + transitive = ( + [ctx.attr.test_binary[DefaultInfo].default_runfiles.files] + + [d[DefaultInfo].default_runfiles.files for d in ctx.attr.data] + + [d[DefaultInfo].default_runfiles.files for d in ctx.attr.data_as_exec] + ) + runfiles = ctx.runfiles( + files = direct_files, + transitive_files = depset(transitive = transitive), + ) + + # Add plugin runfiles (carries plugin data files + py_library runfiles) + for plugin_target in ctx.attr.plugins: + info = plugin_target[PyItfPluginInfo] + runfiles = runfiles.merge(info.plugin_runfiles) + + # Also merge the DefaultInfo runfiles forwarded from py_library + runfiles = runfiles.merge(plugin_target[DefaultInfo].default_runfiles) + + return [ + DefaultInfo( + executable = launcher, + runfiles = runfiles, + ), + RunEnvironmentInfo( + environment = ctx.attr.env, + ), + ] + +_itf_test = rule( + doc = "Wrapper test rule that launches a py_test binary with ITF plugin args.", + implementation = _itf_test_impl, + attrs = { + "test_binary": attr.label( + doc = "The py_test target to wrap.", + cfg = "exec", + executable = True, + mandatory = True, + providers = [PyInfo], + ), + "plugins": attr.label_list( + doc = "List of py_itf_plugin targets.", + providers = [PyItfPluginInfo], + cfg = "exec", + default = [], + ), + "srcs": attr.label_list( + doc = "Test source files (passed as positional args to pytest).", + cfg = "exec", + allow_files = [".py"], + ), + "pytest_ini": attr.label( + doc = "pytest.ini configuration file.", + cfg = "exec", + allow_single_file = True, + mandatory = True, + ), + "data": attr.label_list( + doc = "Data files built for target configuration.", + cfg = "target", + allow_files = True, + default = [], + ), + "data_as_exec": attr.label_list( + doc = "Data files built for exec (host) configuration.", + cfg = "exec", + allow_files = True, + default = [], + ), + "extra_args": attr.string_list( + doc = "User-supplied args (supports $(location ...) against data targets).", + default = [], + ), + "env": attr.string_dict( + doc = "Environment variables for the test.", + default = {}, + ), + }, + test = True, +) + +# ============================================================================= +# Symbolic macro: the public API, creates the py_test + _itf_test pair. +# ============================================================================= + +def _py_itf_test_impl(name, visibility, srcs, args, data, data_as_exec, plugins, deps, tags, **kwargs): + """Symbolic macro implementation for ITF tests.""" + pytest_bootstrap = Label("@score_itf//:main.py") + pytest_ini = Label("@score_itf//:pytest.ini") + + # Internal py_test target: compiles & bundles Python deps. + # Plugins forward DefaultInfo from their py_library, so they work as deps. + py_test( + name = name + ".test_binary", + srcs = [pytest_bootstrap] + srcs, + main = pytest_bootstrap, + deps = [ + "@score_itf//:itf", + ] + deps + plugins, + tags = ["manual"], + visibility = ["//visibility:private"], + ) - test_as_exec( + # Wrapper test rule: resolves plugin providers and launches the py_test. + _itf_test( name = name, - executable = "_" + name, + test_binary = name + ".test_binary", + plugins = plugins, + srcs = srcs, + pytest_ini = pytest_ini, + data = data, data_as_exec = data_as_exec, - data = data + plugin_data, - args = args + - ["-c $(location %s)" % pytest_ini] + - [ - "-p no:cacheprovider", - "--show-capture=no", - ] + - plugin_enable_args + - plugin_args + - ["$(locations %s)" % x for x in srcs], + extra_args = args, env = { "PYTHONDONOTWRITEBYTECODE": "1", }, - tags = tags + plugin_tags, + tags = tags, + visibility = visibility, ) + +py_itf_test = macro( + doc = "Symbolic macro for running ITF tests with pytest.", + implementation = _py_itf_test_impl, + attrs = { + "srcs": attr.label_list(mandatory = True, allow_files = [".py"]), + "args": attr.string_list(default = []), + "data": attr.label_list(default = [], allow_files = True), + "data_as_exec": attr.label_list(default = [], allow_files = True), + "plugins": attr.label_list(default = [], providers = [PyItfPluginInfo]), + "deps": attr.label_list(default = [], providers = [PyInfo]), + }, + inherit_attrs = "common", +) diff --git a/bazel/rules/BUILD b/bazel/rules/BUILD deleted file mode 100644 index 6bdeed2..0000000 --- a/bazel/rules/BUILD +++ /dev/null @@ -1,12 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* diff --git a/bazel/rules/as_exec.bzl b/bazel/rules/as_exec.bzl deleted file mode 100644 index 4465036..0000000 --- a/bazel/rules/as_exec.bzl +++ /dev/null @@ -1,44 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* -""" - Implements a rule to run generators in exec cfg - With this host configuration, generators need to be run only once even if the corresponding results - are built with different bazel configs -""" - -def _as_exec_impl(ctx): - providers = [ - OutputGroupInfo, - CcInfo, - ] - - output = [ - ctx.attr.src[provider] - for provider in providers - if provider in ctx.attr.src - ] - - if DefaultInfo in ctx.attr.src: - output = output + [DefaultInfo(files = ctx.attr.src[DefaultInfo].files, runfiles = ctx.attr.src[DefaultInfo].data_runfiles)] - - return output - -as_exec = rule( - implementation = _as_exec_impl, - attrs = { - "src": attr.label( - allow_files = True, - cfg = "exec", - ), - }, -) diff --git a/bazel/rules/run_as_exec.bzl b/bazel/rules/run_as_exec.bzl deleted file mode 100644 index c829deb..0000000 --- a/bazel/rules/run_as_exec.bzl +++ /dev/null @@ -1,104 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -""" -Runs an executable on execution platform, with runtime deps built with either -target or execution platform configuration. - -Executable rule outputs a symlink to the actual executable, fully leveraging -it's implementation (e.g. reuse a py_binary) and remaining somewhat OS -independent. - -NOTE: This has one caveat, that the symlink is "built" with target -configuration. So do not depend on targets output by this rule unless -you're qualified personnel. -""" - -def run_as_exec(**kwargs): - """This macro remaps the arguments for clarity: - - deps -> data_as_exec: Runtime deps built with execution platform configuration. - """ - data_as_exec = kwargs.pop("data_as_exec", None) - _as_exec_run( - deps = data_as_exec, - **kwargs - ) - -def test_as_exec(**kwargs): - """This macro remaps the arguments for clarity: - - deps -> data_as_exec: Runtime deps built with execution platform configuration. - """ - data_as_exec = kwargs.pop("data_as_exec", None) - _as_exec_test( - deps = data_as_exec, - **kwargs - ) - -_RULE_ATTRS = { - # In order for args expansion to work in bazel for an executable rule - # the attributes must be one of: "srcs", "deps", "data" or "tools". - # See Bazel's LocationExpander implementation, these attribute names - # are hardcoded. - "data": attr.label_list( - allow_files = True, - cfg = "target", - ), - "deps": attr.label_list( - allow_files = True, - cfg = "exec", - ), - "env": attr.string_dict(), - "executable": attr.label( - allow_files = True, - cfg = "exec", - executable = True, - mandatory = True, - ), -} - -def _executable_as_exec_impl(ctx): - link = ctx.actions.declare_file(ctx.attr.name) - ctx.actions.symlink( - output = link, - target_file = ctx.executable.executable, - is_executable = True, - ) - - return [ - DefaultInfo( - executable = link, - runfiles = ctx.runfiles( - files = ctx.files.data + ctx.files.deps + ctx.files.executable, - transitive_files = depset( - transitive = [ctx.attr.executable.default_runfiles.files] + - [dataf.default_runfiles.files for dataf in ctx.attr.data] + - [dataf.data_runfiles.files for dataf in ctx.attr.data], - ), - ), - ), - RunEnvironmentInfo(environment = ctx.attr.env), - ] - -_as_exec_run = rule( - implementation = _executable_as_exec_impl, - attrs = _RULE_ATTRS, - executable = True, -) - -_as_exec_test = rule( - implementation = _executable_as_exec_impl, - attrs = _RULE_ATTRS, - test = True, -) diff --git a/examples/examples/itf/BUILD b/examples/examples/itf/BUILD index 52d5cb1..82ec5b9 100644 --- a/examples/examples/itf/BUILD +++ b/examples/examples/itf/BUILD @@ -11,7 +11,6 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* load("@score_itf//:defs.bzl", "py_itf_test") -load("@score_itf//score/itf/plugins:plugins.bzl", "dlt", "docker", "qemu") py_itf_test( name = "test_docker", @@ -24,7 +23,7 @@ py_itf_test( ], data = ["//examples/docker:image_load"], plugins = [ - docker, + "@score_itf//score/itf/plugins:docker_plugin", ], ) @@ -39,8 +38,8 @@ py_itf_test( # ], # data = ["@score_itf//test/resources:image_tarball"], # plugins = [ -# dlt, -# docker, +# "@score_itf//score/itf/plugins:dlt_plugin", +# "@score_itf//score/itf/plugins:docker_plugin", # ], # ) @@ -58,8 +57,8 @@ py_itf_test( "@score_itf//test/resources:qemu_bridge_config", ], plugins = [ - qemu, - dlt, + "@score_itf//score/itf/plugins:qemu_plugin", + "@score_itf//score/itf/plugins:dlt_plugin", ], tags = [ "manual", @@ -80,8 +79,8 @@ py_itf_test( "@score_itf//test/resources:qemu_port_forwarding_config", ], plugins = [ - qemu, - dlt, + "@score_itf//score/itf/plugins:qemu_plugin", + "@score_itf//score/itf/plugins:dlt_plugin", ], tags = [ "manual", diff --git a/score/itf/plugins/BUILD b/score/itf/plugins/BUILD index c597277..0357a90 100644 --- a/score/itf/plugins/BUILD +++ b/score/itf/plugins/BUILD @@ -12,6 +12,7 @@ # ******************************************************************************* load("@itf_pip//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_library") +load("//bazel:py_itf_plugin.bzl", "py_itf_plugin") py_library( name = "core", @@ -34,3 +35,38 @@ py_library( requirement("pytest"), ], ) + +# ---- ITF plugin targets (used by py_itf_test symbolic macro) ---- + +py_itf_plugin( + name = "docker_plugin", + enabled_plugins = [ + "score.itf.plugins.docker", + ], + py_library = ":docker", + visibility = ["//visibility:public"], +) + +py_itf_plugin( + name = "qemu_plugin", + enabled_plugins = [ + "score.itf.plugins.qemu", + ], + py_library = "//score/itf/plugins/qemu", + visibility = ["//visibility:public"], +) + +py_itf_plugin( + name = "dlt_plugin", + enabled_plugins = [ + "score.itf.plugins.dlt", + ], + plugin_args = [ + "--dlt-receive-path=$(location @score_itf//third_party/dlt:dlt-receive)", + ], + plugin_data_as_exec = [ + "@score_itf//third_party/dlt:dlt-receive", + ], + py_library = "//score/itf/plugins/dlt", + visibility = ["//visibility:public"], +) diff --git a/score/itf/plugins/dlt/BUILD b/score/itf/plugins/dlt/BUILD index b048838..eeb03f4 100644 --- a/score/itf/plugins/dlt/BUILD +++ b/score/itf/plugins/dlt/BUILD @@ -13,16 +13,10 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_python//python:defs.bzl", "py_library") -load("//bazel/rules:as_exec.bzl", "as_exec") - -as_exec( - name = "dlt-library", - src = "//third_party/dlt:libdlt.so", -) copy_file( name = "libdlt", - src = ":dlt-library", + src = "//third_party/dlt:libdlt.so", out = "libdlt.so.2", allow_symlink = True, ) diff --git a/score/itf/plugins/plugins.bzl b/score/itf/plugins/plugins.bzl deleted file mode 100644 index 659fb50..0000000 --- a/score/itf/plugins/plugins.bzl +++ /dev/null @@ -1,61 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -load("//bazel:py_itf_plugin.bzl", "py_itf_plugin") - -docker = py_itf_plugin( - py_library = "@score_itf//score/itf/plugins:docker", - enabled_plugins = [ - "score.itf.plugins.docker", - ], - args = [ - ], - data = [ - ], - data_as_exec = [ - ], - tags = [ - ], -) - -qemu = py_itf_plugin( - py_library = "@score_itf//score/itf/plugins/qemu", - enabled_plugins = [ - "score.itf.plugins.qemu", - ], - args = [ - ], - data = [ - ], - data_as_exec = [ - ], - tags = [ - ], -) - -dlt = py_itf_plugin( - py_library = "@score_itf//score/itf/plugins/dlt", - enabled_plugins = [ - "score.itf.plugins.dlt", - ], - args = [ - "--dlt-receive-path=$(location @score_itf//third_party/dlt:dlt-receive)", - ], - data = [ - ], - data_as_exec = [ - "@score_itf//third_party/dlt:dlt-receive", - ], - tags = [ - ], -) diff --git a/test/BUILD b/test/BUILD index 02d7ef4..eb07986 100644 --- a/test/BUILD +++ b/test/BUILD @@ -11,7 +11,6 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* load("//:defs.bzl", "py_itf_test") -load("//score/itf/plugins:plugins.bzl", "dlt", "docker", "qemu") py_itf_test( name = "test_rules_are_working_correctly", @@ -30,7 +29,7 @@ py_itf_test( "--docker-image=ubuntu:24.04", ], plugins = [ - docker, + "//score/itf/plugins:docker_plugin", ], ) @@ -45,8 +44,8 @@ py_itf_test( ], data = ["//test/resources:image_load"], plugins = [ - dlt, - docker, + "//score/itf/plugins:dlt_plugin", + "//score/itf/plugins:docker_plugin", ], ) @@ -59,10 +58,47 @@ py_itf_test( "--docker-image=linuxserver/openssh-server:version-10.2_p1-r0", ], plugins = [ - docker, + "//score/itf/plugins:docker_plugin", ], ) +py_itf_test( + name = "test_ssh_configurable", + srcs = [ + "test_ssh.py", + ], + args = select( + { + "@platforms//os:qnx": [ + "--qemu-config=$(location //test/resources:qemu_bridge_config)", + "--qemu-image=$(location //test/resources/qnx:init)", + ], + "//conditions:default": [ + "--docker-image=linuxserver/openssh-server:version-10.2_p1-r0", + ], + }, + ), + data = select( + { + "@platforms//os:qnx": [ + "//test/resources:qemu_bridge_config", + "//test/resources/qnx:init", + ], + "//conditions:default": [], + }, + ), + plugins = select( + { + "@platforms//os:qnx": [ + "//score/itf/plugins:qemu_plugin", + ], + "//conditions:default": [ + "//score/itf/plugins:docker_plugin", + ], + }, + ), +) + py_itf_test( name = "test_qemu_bridge_network", srcs = [ @@ -79,8 +115,8 @@ py_itf_test( "//test/resources/qnx:init", ], plugins = [ - qemu, - dlt, + "//score/itf/plugins:qemu_plugin", + "//score/itf/plugins:dlt_plugin", ], tags = [ "local", @@ -102,7 +138,7 @@ py_itf_test( "//test/resources/qnx:init", ], plugins = [ - qemu, + "//score/itf/plugins:qemu_plugin", ], tags = [ "local", @@ -124,8 +160,8 @@ py_itf_test( "//test/resources/qnx:init", ], plugins = [ - qemu, - dlt, + "//score/itf/plugins:qemu_plugin", + "//score/itf/plugins:dlt_plugin", ], tags = [ "local",