test(espidf): assert the two-tier architecture guard (issue #257)

Direct sketch includes of arch-excluded libs merge; transitive pulls
stay skipped; 'all' counts as wildcard. Replaces the old blanket-skip
assertion that correctly blocked the deploy gate.
This commit is contained in:
David Montero 2026-07-31 22:14:39 +02:00
parent d4b0b3d822
commit aa273a56e9
1 changed files with 23 additions and 3 deletions

View File

@ -67,12 +67,27 @@ class TestCoreFirstResolution(unittest.TestCase):
self.assertIn("DHT.cpp", copied)
self.assertEqual(hdr2comp.get("DHT.h"), "user_libs_all")
def test_arch_excluded_lib_skipped(self):
def test_arch_excluded_lib_two_tier_guard(self):
"""Issue #257: the architecture guard is two-tier. A DIRECT sketch
include of an arch-excluded lib merges anyway (user intent; many
avr-declared libs are pure Wire code a real compile error beats
'No such file'). A TRANSITIVE pull of an arch-excluded lib is still
skipped (the Adafruit_ZeroDMA poison path). And 'all' counts as
wildcard (LiquidCrystal_I2C 2.0.0 declares architectures=all)."""
ulibs = self.tmp / "Arduino" / "libraries"
_mk(ulibs / "AvrOnlyLib" / "library.properties",
"name=AvrOnlyLib\narchitectures=avr\n")
_mk(ulibs / "AvrOnlyLib" / "Foo.h")
_mk(ulibs / "AvrOnlyLib" / "Foo.cpp")
# An 'all'-declared lib whose header pulls the avr-only one
# transitively: Bar.h -> #include <Foo2.h>.
_mk(ulibs / "AllArchLib" / "library.properties",
"name=AllArchLib\narchitectures=all\n")
_mk(ulibs / "AllArchLib" / "Bar.h", '#include <Foo2.h>\n')
_mk(ulibs / "AllArchLib" / "Bar.cpp")
_mk(ulibs / "AvrOnlyLib2" / "library.properties",
"name=AvrOnlyLib2\narchitectures=avr\n")
_mk(ulibs / "AvrOnlyLib2" / "Foo2.h")
c = ESPIDFCompiler()
c.arduino_path = "" # no core path -> static fallback set
@ -81,11 +96,16 @@ class TestCoreFirstResolution(unittest.TestCase):
out.mkdir(parents=True)
names, hdr2comp = c._resolve_library_components(
["Foo.h"],
["Foo.h", "Bar.h"],
arduino_libs=ulibs, esp32_libs=None,
arduino_comp_name="arduino-esp32", user_libs_dir=out,
)
self.assertNotIn("Foo.h", hdr2comp)
# Direct include of the avr-only lib: merged anyway.
self.assertEqual(hdr2comp.get("Foo.h"), "user_libs_all")
# 'all' wildcard lib: merged.
self.assertEqual(hdr2comp.get("Bar.h"), "user_libs_all")
# Transitive pull (Foo2.h via Bar.h) of an avr-only lib: skipped.
self.assertNotIn("Foo2.h", hdr2comp)
class TestManifestScope(unittest.TestCase):