Skip to content

Commit 540d960

Browse files
committed
fix: duplicated find argument
1 parent 04aba8a commit 540d960

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

idf_build_apps/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,17 @@ def main():
395395
else:
396396
arguments = BuildArguments(**kwargs_without_none)
397397

398+
if isinstance(arguments, FindArguments):
399+
find_arguments = arguments
400+
else:
401+
find_arguments = FindArguments.model_validate(arguments.model_dump(exclude_none=True))
402+
398403
# real call starts here
399404
# build also needs to find first
400405
apps = find_apps(
401406
arguments.paths,
402407
arguments.target,
403-
find_arguments=FindArguments.model_validate(arguments.model_dump(exclude_none=True)),
408+
find_arguments=find_arguments,
404409
)
405410

406411
if isinstance(arguments, FindArguments): # find only

tests/test_cmd.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,43 @@ def test_manifest_patterns(tmp_path, monkeypatch, capsys):
137137
assert f'"{os.path.join(tmp_path, "bar")}" does not exist' in err
138138

139139

140+
def test_find_with_manifest_patterns_from_config_does_not_duplicate_manifest(tmp_path, monkeypatch, capsys):
141+
(tmp_path / '.idf_build_apps.toml').write_text(
142+
dedent(
143+
"""\
144+
manifest_filepatterns = [
145+
'**/.build-test-rules.yml',
146+
]
147+
"""
148+
)
149+
)
150+
(tmp_path / '.build-test-rules.yml').write_text(
151+
dedent(
152+
"""\
153+
app-one:
154+
enable:
155+
- if: IDF_TARGET == "esp32"
156+
157+
app-two:
158+
enable:
159+
- if: IDF_TARGET == "esp32"
160+
"""
161+
)
162+
)
163+
(tmp_path / 'app-one').mkdir()
164+
(tmp_path / 'app-two').mkdir()
165+
166+
with monkeypatch.context() as m:
167+
m.chdir(tmp_path)
168+
m.setattr(sys, 'argv', ['idf-build-apps', 'find'])
169+
with pytest.raises(SystemExit) as exc_info:
170+
main()
171+
172+
assert exc_info.value.code == 0
173+
_, err = capsys.readouterr()
174+
assert 'is already defined in' not in err
175+
176+
140177
def test_build_include_all_apps(tmp_path, monkeypatch, capsys):
141178
create_project('foo', tmp_path)
142179

0 commit comments

Comments
 (0)