IQ.Pilot Release Commit @ 0b96bd5
This commit is contained in:
@@ -81,6 +81,19 @@ def stale_registry_artifacts(basedir: str = BASEDIR) -> list[str]:
|
||||
return stale
|
||||
|
||||
|
||||
def purge_stale_registry_header(basedir: str = BASEDIR) -> bool:
|
||||
from iqpilot.cereal.services import registry_tag
|
||||
header = os.path.join(basedir, REGISTRY_ARTIFACTS[0])
|
||||
if not os.path.isfile(header):
|
||||
return False
|
||||
with open(header, "rb") as f:
|
||||
stamped = registry_tag().encode() in f.read()
|
||||
if stamped:
|
||||
return False
|
||||
purge_registry_artifacts([], basedir)
|
||||
return True
|
||||
|
||||
|
||||
def purge_registry_artifacts(stale: list[str], basedir: str = BASEDIR) -> None:
|
||||
for rel in set(stale) | set(REGISTRY_ARTIFACTS[:3]):
|
||||
path = os.path.join(basedir, rel)
|
||||
@@ -101,6 +114,9 @@ def build(spinner, dirty: bool = False, minimal: bool = False, show_error_window
|
||||
|
||||
# building with all cores can result in using too
|
||||
# much memory, so retry with less parallelism
|
||||
if purge_stale_registry_header():
|
||||
cloudlog.error("generated service registry header was stale, regenerating")
|
||||
|
||||
compile_output: list[bytes] = []
|
||||
for n in get_job_sequence():
|
||||
compile_output.clear()
|
||||
|
||||
@@ -43,3 +43,23 @@ def test_purge_removes_the_stale_binary_and_the_messaging_table(tmp_path):
|
||||
assert "iqpilot/cereal/messaging/socketmaster.o" not in remaining
|
||||
assert "iqpilot/cereal/libsocketmaster.a" not in remaining
|
||||
assert "iqpilot/system/loggerd/loggerd" in remaining
|
||||
|
||||
|
||||
def test_generated_header_declares_the_stamp_for_the_compile_fallback():
|
||||
assert "#define SERVICES_REGISTRY_STAMPED 1" in build_header()
|
||||
|
||||
|
||||
def test_pre_build_purge_drops_an_unstamped_or_old_header(tmp_path):
|
||||
from iqpilot.system.manager.build import purge_stale_registry_header
|
||||
_write(tmp_path, "iqpilot/cereal/services.h", b"static std::map<std::string, service> services = {};\n")
|
||||
_write(tmp_path, "iqpilot/cereal/messaging/socketmaster.o", b"o")
|
||||
_write(tmp_path, "iqpilot/cereal/libsocketmaster.a", b"a")
|
||||
assert purge_stale_registry_header(str(tmp_path))
|
||||
assert not (tmp_path / "iqpilot/cereal/services.h").exists()
|
||||
assert not (tmp_path / "iqpilot/cereal/messaging/socketmaster.o").exists()
|
||||
assert not (tmp_path / "iqpilot/cereal/libsocketmaster.a").exists()
|
||||
|
||||
_write(tmp_path, "iqpilot/cereal/services.h", build_header().encode())
|
||||
assert not purge_stale_registry_header(str(tmp_path))
|
||||
assert (tmp_path / "iqpilot/cereal/services.h").exists()
|
||||
assert not purge_stale_registry_header(str(tmp_path / "nowhere"))
|
||||
|
||||
Reference in New Issue
Block a user