diff --git a/test/backend/unit/test_espidf_core_first.py b/test/backend/unit/test_espidf_core_first.py index 74f70bfe..10630528 100644 --- a/test/backend/unit/test_espidf_core_first.py +++ b/test/backend/unit/test_espidf_core_first.py @@ -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 . + _mk(ulibs / "AllArchLib" / "library.properties", + "name=AllArchLib\narchitectures=all\n") + _mk(ulibs / "AllArchLib" / "Bar.h", '#include \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):