summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-05 16:51:42 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-05 17:25:45 -0400
commit66574a377a9a86ab64d0c81a5cd4cbecc4a2478b (patch)
treed3db5cae9d98dad2bccbec53a99acff383a1054f
parent8888f60d13181a8070ec9135d2a2dedee60e027d (diff)
downloadbuildstream-66574a377a9a86ab64d0c81a5cd4cbecc4a2478b.tar.gz
tests/completions/completions.py: Testing more completion cases
-rw-r--r--tests/completions/completions.py54
-rw-r--r--tests/completions/no-element-path/compose-all.bst12
-rw-r--r--tests/completions/no-element-path/compose-exclude-dev.bst16
-rw-r--r--tests/completions/no-element-path/compose-include-bin.bst16
-rwxr-xr-xtests/completions/no-element-path/files/bin-files/usr/bin/hello3
-rw-r--r--tests/completions/no-element-path/files/dev-files/usr/include/pony.h12
-rw-r--r--tests/completions/no-element-path/import-bin.bst4
-rw-r--r--tests/completions/no-element-path/import-dev.bst4
-rw-r--r--tests/completions/no-element-path/project.conf2
-rw-r--r--tests/completions/no-element-path/target.bst8
10 files changed, 114 insertions, 17 deletions
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index 4dbb68519..b66950476 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -3,10 +3,7 @@ import pytest
from tests.testutils import cli
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
+DATA_DIR = os.path.dirname(os.path.realpath(__file__))
MAIN_COMMANDS = [
'build ',
@@ -127,7 +124,7 @@ def test_option_choice(cli, cmd, word_idx, expected):
assert_completion(cli, cmd, word_idx, expected)
-@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project'))
@pytest.mark.parametrize("cmd,word_idx,expected,subdir", [
# Note that elements/ and files/ are partial completions and
# as such do not come with trailing whitespace
@@ -151,7 +148,7 @@ def test_option_file(datafiles, cli, cmd, word_idx, expected, subdir):
assert_completion(cli, cmd, word_idx, expected, cwd=cwd)
-@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project'))
@pytest.mark.parametrize("cmd,word_idx,expected,subdir", [
# Note that regular files like project.conf are not returned when
# completing for a directory
@@ -168,26 +165,49 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("cmd,word_idx,expected,subdir", [
+@pytest.mark.parametrize("project,cmd,word_idx,expected,subdir", [
# When running in the project directory
- ('bst show ', 2, [e + ' ' for e in PROJECT_ELEMENTS], None),
- ('bst build com', 2, ['compose-all.bst ', 'compose-include-bin.bst ', 'compose-exclude-dev.bst '], None),
+ ('project', 'bst show ', 2, [e + ' ' for e in PROJECT_ELEMENTS], None),
+ ('project', 'bst build com', 2,
+ ['compose-all.bst ', 'compose-include-bin.bst ', 'compose-exclude-dev.bst '], None),
# When running from the files subdir
- ('bst show ', 2, [], 'files'),
- ('bst build com', 2, [], 'files'),
+ ('project', 'bst show ', 2, [], 'files'),
+ ('project', 'bst build com', 2, [], 'files'),
# When passing the project directory
- ('bst --directory ../ show ', 4, [e + ' ' for e in PROJECT_ELEMENTS], 'files'),
- ('bst --directory ../ build com', 4,
+ ('project', 'bst --directory ../ show ', 4, [e + ' ' for e in PROJECT_ELEMENTS], 'files'),
+ ('project', 'bst --directory ../ build com', 4,
['compose-all.bst ', 'compose-include-bin.bst ', 'compose-exclude-dev.bst '], 'files'),
# Also try multi arguments together
- ('bst --directory ../ checkout t ', 4, ['target.bst '], 'files'),
- ('bst --directory ../ checkout target.bst ', 5, ['bin-files/', 'dev-files/'], 'files'),
+ ('project', 'bst --directory ../ checkout t ', 4, ['target.bst '], 'files'),
+ ('project', 'bst --directory ../ checkout target.bst ', 5, ['bin-files/', 'dev-files/'], 'files'),
+
+ # When running in the project directory
+ ('no-element-path', 'bst show ', 2,
+ [e + ' ' for e in (PROJECT_ELEMENTS + ['project.conf'])] + ['files/'], None),
+ ('no-element-path', 'bst build com', 2,
+ ['compose-all.bst ', 'compose-include-bin.bst ', 'compose-exclude-dev.bst '], None),
+
+ # When running from the files subdir
+ ('no-element-path', 'bst show ', 2, [], 'files'),
+ ('no-element-path', 'bst build com', 2, [], 'files'),
+
+ # When passing the project directory
+ ('no-element-path', 'bst --directory ../ show ', 4,
+ [e + ' ' for e in (PROJECT_ELEMENTS + ['project.conf'])] + ['files/'], 'files'),
+ ('no-element-path', 'bst --directory ../ show f', 4, ['files/'], 'files'),
+ ('no-element-path', 'bst --directory ../ show files/', 4, ['files/bin-files/', 'files/dev-files/'], 'files'),
+ ('no-element-path', 'bst --directory ../ build com', 4,
+ ['compose-all.bst ', 'compose-include-bin.bst ', 'compose-exclude-dev.bst '], 'files'),
+
+ # 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'),
])
-def test_argument_element(datafiles, cli, cmd, word_idx, expected, subdir):
- cwd = str(datafiles)
+def test_argument_element(datafiles, cli, project, cmd, word_idx, expected, subdir):
+ cwd = os.path.join(str(datafiles), project)
if subdir:
cwd = os.path.join(cwd, subdir)
assert_completion(cli, cmd, word_idx, expected, cwd=cwd)
diff --git a/tests/completions/no-element-path/compose-all.bst b/tests/completions/no-element-path/compose-all.bst
new file mode 100644
index 000000000..ba47081b3
--- /dev/null
+++ b/tests/completions/no-element-path/compose-all.bst
@@ -0,0 +1,12 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
diff --git a/tests/completions/no-element-path/compose-exclude-dev.bst b/tests/completions/no-element-path/compose-exclude-dev.bst
new file mode 100644
index 000000000..75c14378c
--- /dev/null
+++ b/tests/completions/no-element-path/compose-exclude-dev.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Exclude the dev domain
+ exclude:
+ - devel
diff --git a/tests/completions/no-element-path/compose-include-bin.bst b/tests/completions/no-element-path/compose-include-bin.bst
new file mode 100644
index 000000000..9571203c6
--- /dev/null
+++ b/tests/completions/no-element-path/compose-include-bin.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Only include the runtim
+ include:
+ - runtime
diff --git a/tests/completions/no-element-path/files/bin-files/usr/bin/hello b/tests/completions/no-element-path/files/bin-files/usr/bin/hello
new file mode 100755
index 000000000..f534a4083
--- /dev/null
+++ b/tests/completions/no-element-path/files/bin-files/usr/bin/hello
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello !"
diff --git a/tests/completions/no-element-path/files/dev-files/usr/include/pony.h b/tests/completions/no-element-path/files/dev-files/usr/include/pony.h
new file mode 100644
index 000000000..40bd0c2e7
--- /dev/null
+++ b/tests/completions/no-element-path/files/dev-files/usr/include/pony.h
@@ -0,0 +1,12 @@
+#ifndef __PONY_H__
+#define __PONY_H__
+
+#define PONY_BEGIN "Once upon a time, there was a pony."
+#define PONY_END "And they lived happily ever after, the end."
+
+#define MAKE_PONY(story) \
+ PONY_BEGIN \
+ story \
+ PONY_END
+
+#endif /* __PONY_H__ */
diff --git a/tests/completions/no-element-path/import-bin.bst b/tests/completions/no-element-path/import-bin.bst
new file mode 100644
index 000000000..a847c0c23
--- /dev/null
+++ b/tests/completions/no-element-path/import-bin.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/bin-files
diff --git a/tests/completions/no-element-path/import-dev.bst b/tests/completions/no-element-path/import-dev.bst
new file mode 100644
index 000000000..152a54667
--- /dev/null
+++ b/tests/completions/no-element-path/import-dev.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/dev-files
diff --git a/tests/completions/no-element-path/project.conf b/tests/completions/no-element-path/project.conf
new file mode 100644
index 000000000..e7e35e716
--- /dev/null
+++ b/tests/completions/no-element-path/project.conf
@@ -0,0 +1,2 @@
+# Project config for frontend build test
+name: test
diff --git a/tests/completions/no-element-path/target.bst b/tests/completions/no-element-path/target.bst
new file mode 100644
index 000000000..b9432fafa
--- /dev/null
+++ b/tests/completions/no-element-path/target.bst
@@ -0,0 +1,8 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
+
+depends:
+- import-bin.bst
+- compose-all.bst