Commit b9dea666 authored by Chandan Singh's avatar Chandan Singh

bst-init: Ensure --element-path is respected by the command

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.
parent 01a02a9a
Pipeline #21984059 passed with stages
in 35 minutes and 43 seconds
......@@ -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`
......
......@@ -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'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment