summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-05-11 12:19:50 +0100
committerChandan Singh <csingh43@bloomberg.net>2018-05-11 12:29:45 +0100
commitb9dea6663be401c5afe8494332328509b9425098 (patch)
treebcb52baeae9e8dd6d6b48d852c858eb59e57f668
parent01a02a9a01c31ece723f88327877781a7a0e24fa (diff)
downloadbuildstream-chandan/fix-bst-init-element-path.tar.gz
bst-init: Ensure --element-path is respected by the commandchandan/fix-bst-init-element-path288-kill-element-normal_name-variable
Previously "elements" was hard-coded as the path for the elements directory whereas it was supposed to be configurable via the `element_path` option to `init_project()`. This led to incorrect behavior when `bst init` was run `--element-path` option. Also, extend tests to test the creation of elements directory. Fixes #398.
-rw-r--r--buildstream/_frontend/app.py4
-rw-r--r--tests/frontend/init.py3
2 files changed, 5 insertions, 2 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index 2ee6a770f..331c35fe2 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -270,14 +270,14 @@ class App():
# Args:
# project_name (str): The project name, must be a valid symbol name
# format_version (int): The project format version, default is the latest version
- # element_directory (str): The subdirectory to store elements in, default is 'elements'
+ # element_path (str): The subdirectory to store elements in, default is 'elements'
# force (bool): Allow overwriting an existing project.conf
#
def init_project(self, project_name, format_version=BST_FORMAT_VERSION, element_path='elements', force=False):
directory = self._main_options['directory']
directory = os.path.abspath(directory)
project_path = os.path.join(directory, 'project.conf')
- elements_path = os.path.join(directory, 'elements')
+ elements_path = os.path.join(directory, element_path)
try:
# Abort if the project.conf already exists, unless `--force` was specified in `bst init`
diff --git a/tests/frontend/init.py b/tests/frontend/init.py
index be7415cf0..8955ae395 100644
--- a/tests/frontend/init.py
+++ b/tests/frontend/init.py
@@ -37,6 +37,9 @@ def test_all_options(cli, tmpdir):
assert project_conf['format-version'] == str(2)
assert project_conf['element-path'] == 'ponies'
+ elements_dir = os.path.join(project, 'ponies')
+ assert os.path.isdir(elements_dir)
+
def test_no_project_name(cli, tmpdir):
result = cli.run(project=str(tmpdir), args=['init'])