From dde78ca7442e6d2b6790969e6f498378fb2be295 Mon Sep 17 00:00:00 2001 From: aqua Date: Sun, 18 Aug 2024 13:52:19 +0300 Subject: Moved pytest to private --- tools/interface_generator/BUILD.bazel | 3 ++- tools/interface_generator/MODULE.bazel | 3 +++ tools/interface_generator/defs.bzl | 22 ---------------------- tools/interface_generator/private/BUILD.bazel | 5 +++++ tools/interface_generator/private/defs.bzl | 22 ++++++++++++++++++++++ .../interface_generator/private/pytest_wrapper.py | 7 +++++++ tools/interface_generator/pytest_wrapper.py | 7 ------- 7 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 tools/interface_generator/private/BUILD.bazel create mode 100644 tools/interface_generator/private/defs.bzl create mode 100755 tools/interface_generator/private/pytest_wrapper.py delete mode 100755 tools/interface_generator/pytest_wrapper.py diff --git a/tools/interface_generator/BUILD.bazel b/tools/interface_generator/BUILD.bazel index 15fbb5d..e62d7b9 100644 --- a/tools/interface_generator/BUILD.bazel +++ b/tools/interface_generator/BUILD.bazel @@ -1,6 +1,7 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements") load("@pip//:requirements.bzl", "requirement") -load(":defs.bzl", "generate_interface", "py_pytest") +load(":defs.bzl", "generate_interface") +load("//private:defs.bzl", "py_pytest") package(default_visibility = ["//visibility:public"]) diff --git a/tools/interface_generator/MODULE.bazel b/tools/interface_generator/MODULE.bazel index b5cbae6..53b2ba4 100644 --- a/tools/interface_generator/MODULE.bazel +++ b/tools/interface_generator/MODULE.bazel @@ -5,6 +5,9 @@ # For more details, please check https://github.com/bazelbuild/bazel/issues/18958 ############################################################################### +module(name = "interface_generator", version = "0.1.0") + +# external dependencies bazel_dep(name = "googletest", version = "1.15.2") bazel_dep(name = "rules_python", version = "0.34.0") diff --git a/tools/interface_generator/defs.bzl b/tools/interface_generator/defs.bzl index 6f02b1f..d5c6f91 100644 --- a/tools/interface_generator/defs.bzl +++ b/tools/interface_generator/defs.bzl @@ -1,5 +1,3 @@ -load("@pip//:requirements.bzl", "requirement") - def _generate_interface_impl(ctx): out_hdrs = [ ctx.actions.declare_file(ctx.attr.interface + ".h"), @@ -53,23 +51,3 @@ def generate_interface(name, interface, license, visibility = None): license = license, visibility = visibility, ) - -def py_pytest(name, srcs, deps = [], **kwargs): - native.py_test( - name = name, - srcs = ["//:pytest_wrapper.py"], - main = "//:pytest_wrapper.py", - data = srcs, - args = [ - "--black", - "--pylint", - #"--mypy", - ] + ["$(location :%s)" % x for x in srcs], - deps = [ - requirement("pytest"), - requirement("pytest-black"), - requirement("pytest-pylint"), - requirement("pytest-mypy"), - ] + deps, - **kwargs - ) diff --git a/tools/interface_generator/private/BUILD.bazel b/tools/interface_generator/private/BUILD.bazel new file mode 100644 index 0000000..46436ee --- /dev/null +++ b/tools/interface_generator/private/BUILD.bazel @@ -0,0 +1,5 @@ +""" targets internal to the tool and rule """ + +package(default_visibility = ["//:__pkg__"]) + +exports_files(["pytest_wrapper.py"]) diff --git a/tools/interface_generator/private/defs.bzl b/tools/interface_generator/private/defs.bzl new file mode 100644 index 0000000..080f19a --- /dev/null +++ b/tools/interface_generator/private/defs.bzl @@ -0,0 +1,22 @@ +load("@pip//:requirements.bzl", "requirement") + +def py_pytest(name, srcs, deps = [], **kwargs): + native.py_test( + name = name, + srcs = ["//private:pytest_wrapper.py"], + main = "//private:pytest_wrapper.py", + data = srcs, + args = [ + "--black", + "--pylint", + #"--mypy", + ] + ["$(location :%s)" % x for x in srcs], + deps = [ + requirement("pytest"), + requirement("pytest-black"), + requirement("pytest-pylint"), + requirement("pytest-mypy"), + ] + deps, + **kwargs + ) + diff --git a/tools/interface_generator/private/pytest_wrapper.py b/tools/interface_generator/private/pytest_wrapper.py new file mode 100755 index 0000000..b4def3b --- /dev/null +++ b/tools/interface_generator/private/pytest_wrapper.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys +import pytest + +if __name__ == "__main__": + sys.exit(pytest.main(sys.argv[1:])) diff --git a/tools/interface_generator/pytest_wrapper.py b/tools/interface_generator/pytest_wrapper.py deleted file mode 100755 index b4def3b..0000000 --- a/tools/interface_generator/pytest_wrapper.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import pytest - -if __name__ == "__main__": - sys.exit(pytest.main(sys.argv[1:])) -- cgit v1.2.1