Skip to content
Snippets Groups Projects
Commit 83710050 authored by Martin Blanchard's avatar Martin Blanchard Committed by Valentin David
Browse files

complete.py: Ensure paths get completed from 'element-path'

Element paths should always be completed from the root element folder
defined by the element-path key in project.conf. Fix complete_path() to
always search into its given base_directory argument.

See issue #448
parent 41d97b7e
No related branches found
No related tags found
1 merge request!652Fix autocompletion for elements in sub-folders
Pipeline #27827420 passed
......@@ -68,9 +68,10 @@ def complete_path(path_type, incomplete, base_directory='.'):
# If there was nothing on the left of the last separator,
# we are completing files in the filesystem root
base_path = os.path.join(base_directory, base_path)
elif os.path.isdir(incomplete):
base_path = incomplete
else:
incomplete_base_path = os.path.join(base_directory, incomplete)
if os.path.isdir(incomplete_base_path):
base_path = incomplete_base_path
try:
if base_path:
......
......@@ -212,6 +212,10 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
# Also try multi arguments together
('no-element-path', 'bst --directory ../ checkout t ', 4, ['target.bst '], 'files'),
('no-element-path', 'bst --directory ../ checkout target.bst ', 5, ['bin-files/', 'dev-files/'], 'files'),
# When element-path have sub-folders
('sub-folders', 'bst show base', 2, ['base/wanted.bst '], None),
('sub-folders', 'bst show base/', 2, ['base/wanted.bst '], None),
])
def test_argument_element(datafiles, cli, project, cmd, word_idx, expected, subdir):
cwd = os.path.join(str(datafiles), project)
......
kind: autotools
description: |
Not auto-completed element
kind: stack
description: Base stack
depends:
- base/wanted.bst
kind: autotools
description: |
Auto-completed element
kind: autotools
description: |
Hello world
# Project config for frontend build test
name: test
element-path: elements
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment