From 20fbca263d1c355e58384e4736fc98fe16392ba8 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 26 Sep 2024 09:46:44 +0200 Subject: [PATCH 1/2] change: add debug info --- idf_build_apps/manifest/manifest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/idf_build_apps/manifest/manifest.py b/idf_build_apps/manifest/manifest.py index f8bbd4d..5e473e4 100644 --- a/idf_build_apps/manifest/manifest.py +++ b/idf_build_apps/manifest/manifest.py @@ -256,6 +256,7 @@ def from_files(cls, paths: t.Iterable[PathLike], *, root_path: str = os.curdir) rules: t.List[FolderRule] = [] for path in paths: + LOGGER.debug('Loading manifest file %s', path) _manifest = cls.from_file(path, root_path=root_path) for rule in _manifest.rules: @@ -351,11 +352,14 @@ def _path(x): return x for folder, sha_value in recorded__rel_folder__sha__dict.items(): + # removed if folder not in self__rel_folder__sha__dict: diff_folders.add(_path(folder)) + # modified elif sha_value != self__rel_folder__sha__dict[folder]: diff_folders.add(_path(folder)) + # new for folder in self__rel_folder__sha__dict: if folder not in recorded__rel_folder__sha__dict: diff_folders.add(_path(folder)) From 90a76f314c1e4c75a7da7abc7e912339a1c49841 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 26 Sep 2024 09:48:58 +0200 Subject: [PATCH 2/2] fix: stop using lambda functions since they cannot be pickled --- idf_build_apps/manifest/if_parser.py | 12 ++++++++++-- tests/conftest.py | 13 +++++++++++++ tests/test_cmd.py | 8 +++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/idf_build_apps/manifest/if_parser.py b/idf_build_apps/manifest/if_parser.py index 32ff1c5..7ae66b5 100644 --- a/idf_build_apps/manifest/if_parser.py +++ b/idf_build_apps/manifest/if_parser.py @@ -178,6 +178,14 @@ class BoolExpr(Stmt): pass +def _and(_l, _r): + return _l and _r + + +def _or(_l, _r): + return _l or _r + + class BoolOrAnd(BoolExpr): def __init__(self, t: ParseResults): if len(t[0]) > 3: @@ -189,9 +197,9 @@ def __init__(self, t: ParseResults): self.right: BoolStmt = t[0][2] if t[0][1] == 'and': - self.operation = lambda l, r: l and r # noqa: E741 + self.operation = _and if t[0][1] == 'or': - self.operation = lambda l, r: l or r # noqa: E741 + self.operation = _or def get_value(self, target: str, config_name: str) -> Any: return self.operation(self.left.get_value(target, config_name), self.right.get_value(target, config_name)) diff --git a/tests/conftest.py b/tests/conftest.py index 335ad22..a92d068 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -66,3 +66,16 @@ def sha_of_enable_only_esp32(): ) return sha + + +@pytest.fixture +def sha_of_enable_esp32_or_esp32s2(): + sha = FolderRule('test1', enable=[{'if': 'IDF_TARGET == "esp32" or IDF_TARGET == "esp32s2"'}]).sha + + # !!! ONLY CHANGE IT WHEN NECESSARY !!! + assert ( + sha + == 'f3408e9bf1d6b9a9e14559e6567917986678a3414229b29f96493aec4dc1bc3e6d0ecc4f79adced0d5c26bc1cd80a4d15fe6aaefa5d1e7033a58290374f4fc7f' # noqa: E501 + ) + + return sha diff --git a/tests/test_cmd.py b/tests/test_cmd.py index 39fc933..ce701b1 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -19,7 +19,9 @@ (['--manifest-files', 'test.yml', '--output', 'test.sha1'], None), ], ) -def test_manifest_dump_sha_values(args, expected_error, sha_of_enable_only_esp32, capsys, monkeypatch): +def test_manifest_dump_sha_values( + args, expected_error, sha_of_enable_only_esp32, sha_of_enable_esp32_or_esp32s2, capsys, monkeypatch +): Path('test.yml').write_text( """ foo: @@ -31,6 +33,9 @@ def test_manifest_dump_sha_values(args, expected_error, sha_of_enable_only_esp32 baz: enable: - if: IDF_TARGET == "esp32" +foobar: + enable: + - if: IDF_TARGET == "esp32" or IDF_TARGET == "esp32s2" """, encoding='utf8', ) @@ -60,4 +65,5 @@ def test_manifest_dump_sha_values(args, expected_error, sha_of_enable_only_esp32 f'bar:{sha_of_enable_only_esp32}\n' f'baz:{sha_of_enable_only_esp32}\n' f'foo:{sha_of_enable_only_esp32}\n' + f'foobar:{sha_of_enable_esp32_or_esp32s2}\n' )