summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Smyth <phillip.smyth@codethink.co.uk>2018-08-01 12:05:40 +0000
committerPhillip Smyth <phillip.smyth@codethink.co.uk>2018-08-01 12:05:40 +0000
commitd10e4668e79155c406fbe726be9458261083f3d7 (patch)
treed7c40608828565de4bce487fd8855b778eb79ca8
parent480565c2ee6c7684c1d48cd518893ce12fc2f58d (diff)
parent87edf67e46b0d8bc7a2d5479c129c6da1cb43a71 (diff)
downloadbuildstream-d10e4668e79155c406fbe726be9458261083f3d7.tar.gz
Merge branch 'mablanch/448-autocompletion-broken-defaults' into 'master'
Fix autocompletion for elements in sub-folders See merge request BuildStream/buildstream!592
-rw-r--r--buildstream/_frontend/complete.py7
-rw-r--r--tests/completions/completions.py4
-rw-r--r--tests/completions/sub-folders/base/unwanted.bst4
-rw-r--r--tests/completions/sub-folders/elements/base.bst5
-rw-r--r--tests/completions/sub-folders/elements/base/wanted.bst4
-rw-r--r--tests/completions/sub-folders/elements/hello.bst4
-rw-r--r--tests/completions/sub-folders/project.conf4
7 files changed, 29 insertions, 3 deletions
diff --git a/buildstream/_frontend/complete.py b/buildstream/_frontend/complete.py
index 79bb92758..97d6d45ec 100644
--- a/buildstream/_frontend/complete.py
+++ b/buildstream/_frontend/complete.py
@@ -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:
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index 1ff026ea5..50b41f7b3 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -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)
diff --git a/tests/completions/sub-folders/base/unwanted.bst b/tests/completions/sub-folders/base/unwanted.bst
new file mode 100644
index 000000000..bd510513d
--- /dev/null
+++ b/tests/completions/sub-folders/base/unwanted.bst
@@ -0,0 +1,4 @@
+kind: autotools
+description: |
+
+ Not auto-completed element
diff --git a/tests/completions/sub-folders/elements/base.bst b/tests/completions/sub-folders/elements/base.bst
new file mode 100644
index 000000000..4e97e8ac0
--- /dev/null
+++ b/tests/completions/sub-folders/elements/base.bst
@@ -0,0 +1,5 @@
+kind: stack
+description: Base stack
+
+depends:
+- base/wanted.bst
diff --git a/tests/completions/sub-folders/elements/base/wanted.bst b/tests/completions/sub-folders/elements/base/wanted.bst
new file mode 100644
index 000000000..57656210d
--- /dev/null
+++ b/tests/completions/sub-folders/elements/base/wanted.bst
@@ -0,0 +1,4 @@
+kind: autotools
+description: |
+
+ Auto-completed element
diff --git a/tests/completions/sub-folders/elements/hello.bst b/tests/completions/sub-folders/elements/hello.bst
new file mode 100644
index 000000000..93fcaa04b
--- /dev/null
+++ b/tests/completions/sub-folders/elements/hello.bst
@@ -0,0 +1,4 @@
+kind: autotools
+description: |
+
+ Hello world
diff --git a/tests/completions/sub-folders/project.conf b/tests/completions/sub-folders/project.conf
new file mode 100644
index 000000000..854e38693
--- /dev/null
+++ b/tests/completions/sub-folders/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements