1# Copyright 2023 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"" 16 17load("@rules_testing//lib:test_suite.bzl", "test_suite") 18load("//python/private/pypi:whl_repo_name.bzl", "whl_repo_name") # buildifier: disable=bzl-visibility 19 20_tests = [] 21 22def _test_simple(env): 23 got = whl_repo_name("prefix", "foo-1.2.3-py3-none-any.whl", "deadbeef") 24 env.expect.that_str(got).equals("prefix_foo_py3_none_any_deadbeef") 25 26_tests.append(_test_simple) 27 28def _test_sdist(env): 29 got = whl_repo_name("prefix", "foo-1.2.3.tar.gz", "deadbeef000deadbeef") 30 env.expect.that_str(got).equals("prefix_foo_sdist_deadbeef") 31 32_tests.append(_test_sdist) 33 34def _test_platform_whl(env): 35 got = whl_repo_name( 36 "prefix", 37 "foo-1.2.3-cp39.cp310-abi3-manylinux1_x86_64.manylinux_2_17_x86_64.whl", 38 "deadbeef000deadbeef", 39 ) 40 41 # We only need the first segment of each 42 env.expect.that_str(got).equals("prefix_foo_cp39_abi3_manylinux_2_5_x86_64_deadbeef") 43 44_tests.append(_test_platform_whl) 45 46def whl_repo_name_test_suite(name): 47 """Create the test suite. 48 49 Args: 50 name: the name of the test suite 51 """ 52 test_suite(name = name, basic_tests = _tests) 53