aboutsummaryrefslogtreecommitdiff
path: root/tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl')
-rw-r--r--tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl b/tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl
new file mode 100644
index 0000000..4408592
--- /dev/null
+++ b/tools/build_defs/python/tests/py_wheel/py_wheel_tests.bzl
@@ -0,0 +1,39 @@
+"""Test for py_wheel."""
+
+load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
+load("@rules_testing//lib:truth.bzl", "matching")
+load("@rules_testing//lib:util.bzl", rt_util = "util")
+load("//python:packaging.bzl", "py_wheel")
+load("//tools/build_defs/python/tests:util.bzl", pt_util = "util")
+
+_tests = []
+
+def _test_too_long_project_url_label(name, config):
+ rt_util.helper_target(
+ config.rule,
+ name = name + "_wheel",
+ distribution = name + "_wheel",
+ python_tag = "py3",
+ version = "0.0.1",
+ project_urls = {"This is a label whose length is above the limit!": "www.example.com"},
+ )
+ analysis_test(
+ name = name,
+ target = name + "_wheel",
+ impl = _test_too_long_project_url_label_impl,
+ expect_failure = True,
+ )
+
+def _test_too_long_project_url_label_impl(env, target):
+ env.expect.that_target(target).failures().contains_predicate(
+ matching.str_matches("in `project_urls` is too long"),
+ )
+
+_tests.append(_test_too_long_project_url_label)
+
+def py_wheel_test_suite(name):
+ config = struct(rule = py_wheel, base_test_rule = py_wheel)
+ native.test_suite(
+ name = name,
+ tests = pt_util.create_tests(_tests, config = config),
+ )