diff options
author | Yuval Peress <peress@chromium.org> | 2021-02-01 13:25:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-04 23:10:19 +0000 |
commit | eb6198328a6829d9ccb5a9c913a6436aaa66f704 (patch) | |
tree | d59f8f61434fcc290e2e4e0036f56c145b62cc12 /zephyr/zmake/tests/test_util.py | |
parent | 5019a83fef6d5d8c03dd93964dd7403f7339f450 (diff) | |
download | chrome-ec-eb6198328a6829d9ccb5a9c913a6436aaa66f704.tar.gz |
zmake: enable default build directory for configure subcommand
Allow zmake to create a default build directory when running zmake
configure. This provides a similar behavior to platform/ec's make
system. Projects will be placed under platform/ec/build/zephyr/...
BRANCH=none
BUG=none
TEST=Added unit test
TEST=zmake configure -b zephyr/projects/volteer
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: Icabed1b77cf5876a75898322d39806237e05d520
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2665071
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/zmake/tests/test_util.py')
-rw-r--r-- | zephyr/zmake/tests/test_util.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/zephyr/zmake/tests/test_util.py b/zephyr/zmake/tests/test_util.py new file mode 100644 index 0000000000..7d48dc15b2 --- /dev/null +++ b/zephyr/zmake/tests/test_util.py @@ -0,0 +1,51 @@ +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import hypothesis +import hypothesis.strategies as st +import pathlib +import pytest + +import zmake.util as util + + +# Strategies for use with hypothesis +absolute_path = st.from_regex(regex=r"\A/\w+[\w/]*\Z") +relative_path = st.from_regex(regex=r"\A\w+[\w/]*\Z") + + +@hypothesis.given(absolute_path, relative_path, relative_path) +def test_resolve_build_dir_with_build_dir(platform_ec_dir, project_subdir, + build_subdir): + platform_ec_dir = pathlib.PosixPath(platform_ec_dir) + build_dir = util.resolve_build_dir( + platform_ec_dir=platform_ec_dir, + project_dir=platform_ec_dir / project_subdir, + build_dir=platform_ec_dir / build_subdir) + + assert build_dir == platform_ec_dir / build_subdir + + +@hypothesis.given(absolute_path, relative_path) +def test_resolve_build_dir_default_dir(platform_ec_dir, project_subdir): + platform_ec_dir = pathlib.PosixPath(platform_ec_dir) + build_dir = util.resolve_build_dir( + platform_ec_dir=platform_ec_dir, + project_dir=platform_ec_dir / project_subdir, + build_dir=None) + assert build_dir == platform_ec_dir / 'build' / project_subdir + + +@hypothesis.given(absolute_path, relative_path) +def test_resolve_build_dir_not_platform_ec_subdir(root_dir, sub_dir): + """In this case, the platform_ec_dir is a subdirectory of the project.""" + root_dir = pathlib.PosixPath(root_dir) + try: + util.resolve_build_dir( + platform_ec_dir=root_dir / sub_dir, + project_dir=root_dir, + build_dir=None) + pytest.fail() + except Exception: + pass |