|
| 1 | +import runpy |
| 2 | +from pathlib import Path |
| 3 | + |
| 4 | +import pytest |
| 5 | + |
| 6 | +promotion = runpy.run_path(str(Path(__file__).with_name("copy-to-distro-specific-channel.py"))) |
| 7 | +belongs_to_distro = promotion["belongs_to_distro"] |
| 8 | + |
| 9 | + |
| 10 | +@pytest.mark.parametrize( |
| 11 | + ("dependencies", "expected"), |
| 12 | + [ |
| 13 | + (["ros2-distro-mutex 0.10.* humble_*"], True), |
| 14 | + ( |
| 15 | + [ |
| 16 | + "ros2-distro-mutex >=0.10.0,<0.11.0a0", |
| 17 | + "ros2-distro-mutex 0.10.* humble_*", |
| 18 | + ], |
| 19 | + True, |
| 20 | + ), |
| 21 | + (["ros2-distro-mutex 0.10.* jazzy_*"], False), |
| 22 | + (["ros2-distro-mutex >=0.10.0,<0.11.0a0"], False), |
| 23 | + (["ros2-distro-mutex 0.10.* *"], False), |
| 24 | + (["ros2-distro-mutex 0.10.* humble-other_*"], False), |
| 25 | + (["ros2-rcl 16.*"], False), |
| 26 | + ([], False), |
| 27 | + ], |
| 28 | +) |
| 29 | +def test_renamed_package_requires_distro_build_pin(dependencies: list[str], expected: bool) -> None: |
| 30 | + artifact = {"name": "ros2-rclcpp", "depends": dependencies} |
| 31 | + assert belongs_to_distro(artifact, "humble") is expected |
| 32 | + |
| 33 | + |
| 34 | +def test_legacy_packages_and_shims_remain_distro_specific() -> None: |
| 35 | + shim = {"name": "ros-humble-rclcpp", "depends": ["ros2-rclcpp ==16.0.19"]} |
| 36 | + assert belongs_to_distro(shim, "humble") |
| 37 | + assert not belongs_to_distro(shim, "jazzy") |
| 38 | + assert belongs_to_distro({"name": "ros-noetic-roscpp"}, "noetic") |
| 39 | + assert not belongs_to_distro({"name": "ros-humble-other-rclcpp"}, "hum") |
| 40 | + |
| 41 | + |
| 42 | +@pytest.mark.parametrize( |
| 43 | + ("name", "build", "distro", "expected"), |
| 44 | + [ |
| 45 | + ("ros2-distro-mutex", "humble_20", "humble", True), |
| 46 | + ("ros2-distro-mutex", "humble", "humble", True), |
| 47 | + ("ros2-distro-mutex", "jazzy_20", "humble", False), |
| 48 | + ("ros2-distro-mutex", "not-humble_20", "humble", False), |
| 49 | + ("ros-distro-mutex", "noetic_1", "noetic", True), |
| 50 | + ], |
| 51 | +) |
| 52 | +def test_mutex_build_identifies_its_distro( |
| 53 | + name: str, build: str, distro: str, expected: bool |
| 54 | +) -> None: |
| 55 | + assert belongs_to_distro({"name": name, "build": build}, distro) is expected |
0 commit comments