[rp2] Rename rp2040 platform to rp2 (#17145)

Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Jesse Hills
2026-07-07 08:20:24 +12:00
committed by GitHub
co-authored by Jonathan Swoboda
parent 9caf431740
commit cdd334284e
153 changed files with 1297 additions and 1062 deletions
+30
View File
@@ -591,6 +591,36 @@ class TestEsphomeCore:
assert target.is_esp32 is False
assert target.is_esp8266 is True
def test_is_rp2(self, target):
"""The canonical RP2 family gate flips on for the rp2 platform."""
target.data[const.KEY_CORE] = {const.KEY_TARGET_PLATFORM: "rp2"}
assert target.is_rp2 is True
assert target.is_esp32 is False
assert target.is_esp8266 is False
def test_is_rp2040_deprecated_alias_matches_is_rp2(self, target, caplog):
"""``is_rp2040`` is kept as a deprecation shim that returns whatever
``is_rp2`` returns; both must agree across platform values. A
one-shot deprecation warning is emitted on first access and
deduped via ``CORE.data`` for the rest of the run."""
import logging
target.data[const.KEY_CORE] = {const.KEY_TARGET_PLATFORM: "rp2"}
with caplog.at_level(logging.WARNING, logger="esphome.core"):
assert target.is_rp2040 is True
assert target.is_rp2040 == target.is_rp2
warnings = [r for r in caplog.records if "is_rp2040" in r.message]
assert len(warnings) == 1
assert "2027.7.0" in warnings[0].message
# Reset the dedupe so the False-platform branch also runs the shim.
target.data.pop("_core_is_rp2040_deprecated_warned", None)
target.data[const.KEY_CORE] = {const.KEY_TARGET_PLATFORM: "esp32"}
assert target.is_rp2040 is False
assert target.is_rp2040 == target.is_rp2
def test_firmware_bin__default(self, target):
"""Default platforms produce <pioenvs>/<name>/firmware.bin."""
target.name = "test-device"