Skip to content

Commit 2f2af0e

Browse files
committed
add packaging test
1 parent 41a4131 commit 2f2af0e

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
8484
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
8585
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
8686
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
87+
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
8788

8889
# Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests.
8990
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.

tests/packaging/BUILD.bazel

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 The Bazel Authors. All rights reserved.
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+
15+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
16+
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
17+
load("//python:py_binary.bzl", "py_binary")
18+
load("//tests/support:sh_py_run_test.bzl", "py_reconfig_test")
19+
20+
build_test(
21+
name = "bzl_libraries_build_test",
22+
targets = [
23+
# keep sorted
24+
":bin_tar",
25+
],
26+
)
27+
28+
py_reconfig_test(
29+
name = "bin_bootstrap_script",
30+
srcs = ["bin.py"],
31+
bootstrap_impl = "script",
32+
main = "bin.py",
33+
relative_venv_symlinks = "no",
34+
)
35+
36+
pkg_tar(
37+
name = "bin_tar",
38+
testonly = True,
39+
srcs = [":bin"],
40+
include_runfiles = True,
41+
)

tests/packaging/bin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello")

tests/support/sh_py_run_test.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,16 @@ def py_reconfig_test(*, name, **kwargs):
132132
name: str, name of teset target.
133133
**kwargs: kwargs to pass along to _py_reconfig_test and py_test.
134134
"""
135-
reconfig_kwargs = {}
136-
reconfig_kwargs["bootstrap_impl"] = kwargs.pop("bootstrap_impl", None)
137-
reconfig_kwargs["extra_toolchains"] = kwargs.pop("extra_toolchains", None)
138-
reconfig_kwargs["python_version"] = kwargs.pop("python_version", None)
135+
reconfig_only_kwarg_names = [
136+
"bootstrap_impl",
137+
"extra_toolchains",
138+
"python_version",
139+
"relative_venv_symlinks",
140+
]
141+
reconfig_kwargs = {
142+
key: kwargs.pop(key, None)
143+
for key in reconfig_only_kwarg_names
144+
}
139145
reconfig_kwargs["target_compatible_with"] = kwargs.get("target_compatible_with")
140146

141147
inner_name = "_{}_inner".format(name)
@@ -144,6 +150,7 @@ def py_reconfig_test(*, name, **kwargs):
144150
target = inner_name,
145151
**reconfig_kwargs
146152
)
153+
147154
py_test(
148155
name = inner_name,
149156
tags = ["manual"],

0 commit comments

Comments
 (0)