diff options
author | Jeremy Bettis <jbettis@google.com> | 2021-03-30 14:34:16 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-31 18:58:26 +0000 |
commit | 9b918d35a2a5573405250e1dfeef084f40ef0c99 (patch) | |
tree | c2e1eec258d694f63570b6c2505c22a65d559e9b /zephyr/zmake/tests/test_project.py | |
parent | 68da2a47999aa5f2a6398bbadebc0b859bce63f3 (diff) | |
download | chrome-ec-9b918d35a2a5573405250e1dfeef084f40ef0c99.tar.gz |
zephyr: Add find_projects() to zmake.project.
A new generator function which searches subdirectories for zmake
projects.
BUG=b:183007888
TEST=zmake testall
BRANCH=none
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Change-Id: Iceca946a12e0e64a46c5994366734addb3e24cb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2795931
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/zmake/tests/test_project.py')
-rw-r--r-- | zephyr/zmake/tests/test_project.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/zephyr/zmake/tests/test_project.py b/zephyr/zmake/tests/test_project.py index 9b5cd8fe35..732e397354 100644 --- a/zephyr/zmake/tests/test_project.py +++ b/zephyr/zmake/tests/test_project.py @@ -124,3 +124,41 @@ def test_prune_modules_unavailable(): 'modules': ['hal_stm32', 'cmsis']}) as project: with pytest.raises(KeyError): project.prune_modules(module_paths) + + +def test_find_projects_empty(tmp_path): + """Test the find_projects method when there are no projects.""" + projects = list(zmake.project.find_projects(tmp_path)) + assert len(projects) == 0 + + +YAML_FILE = """ +supported-zephyr-versions: + - v2.5 +toolchain: coreboot-sdk +output-type: npcx +""" + + +def test_find_projects(tmp_path): + """Test the find_projects method when there are projects.""" + dir = tmp_path.joinpath('one') + dir.mkdir() + dir.joinpath('zmake.yaml').write_text("board: one\n" + YAML_FILE) + tmp_path.joinpath('two').mkdir() + dir = tmp_path.joinpath('two/a') + dir.mkdir() + dir.joinpath('zmake.yaml').write_text( + "board: twoa\nis-test: true\n" + YAML_FILE) + dir = tmp_path.joinpath('two/b') + dir.mkdir() + dir.joinpath('zmake.yaml').write_text("board: twob\n" + YAML_FILE) + projects = list(zmake.project.find_projects(tmp_path)) + projects.sort(key=lambda x: x.project_dir) + assert len(projects) == 3 + assert projects[0].project_dir == tmp_path.joinpath('one') + assert projects[1].project_dir == tmp_path.joinpath('two/a') + assert projects[2].project_dir == tmp_path.joinpath('two/b') + assert not projects[0].config.is_test + assert projects[1].config.is_test + assert not projects[2].config.is_test |