Skip to content

Commit 5c5a818

Browse files
authored
test: add test case for normalize_version (#1339)
### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - New test cases added
1 parent 14a1036 commit 5c5a818

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

uv/private/normalize_version_test.bzl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,24 @@ def _normalize_version_epoch_test_impl(ctx):
2525

2626
normalize_version_epoch_test = unittest.make(_normalize_version_epoch_test_impl)
2727

28+
def _normalize_version_local_test_impl(ctx):
29+
"""PEP 440 local versions (e.g. ``0.4.25+cuda11.cudnn86``) must not leak ``+`` into repo names."""
30+
env = unittest.begin(ctx)
31+
version = "0.4.25+cuda11.cudnn86"
32+
out = normalize_version(version)
33+
asserts.true(
34+
env,
35+
_is_valid_repo_name_component(out),
36+
"normalize_version(%r) = %r contains characters invalid in a Bazel repo name" % (version, out),
37+
)
38+
asserts.false(env, "+" in out, "normalize_version(%r) = %r must not retain '+'" % (version, out))
39+
return unittest.end(env)
40+
41+
normalize_version_local_test = unittest.make(_normalize_version_local_test_impl)
42+
2843
def normalize_version_test_suite():
2944
unittest.suite(
3045
"normalize_version_tests",
3146
normalize_version_epoch_test,
47+
normalize_version_local_test,
3248
)

0 commit comments

Comments
 (0)