summaryrefslogtreecommitdiff
path: root/tests/frontend/completions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/frontend/completions.py')
-rw-r--r--tests/frontend/completions.py160
1 files changed, 24 insertions, 136 deletions
diff --git a/tests/frontend/completions.py b/tests/frontend/completions.py
index 075fd70f1..3603543c7 100644
--- a/tests/frontend/completions.py
+++ b/tests/frontend/completions.py
@@ -84,13 +84,7 @@ MIXED_ELEMENTS = PROJECT_ELEMENTS + INVALID_ELEMENTS
def assert_completion(cli, cmd, word_idx, expected, cwd=None):
result = cli.run(
- project=".",
- cwd=cwd,
- env={
- "_BST_COMPLETION": "complete",
- "COMP_WORDS": cmd,
- "COMP_CWORD": str(word_idx),
- },
+ project=".", cwd=cwd, env={"_BST_COMPLETION": "complete", "COMP_WORDS": cmd, "COMP_CWORD": str(word_idx),},
)
words = []
if result.output:
@@ -105,14 +99,7 @@ def assert_completion(cli, cmd, word_idx, expected, cwd=None):
def assert_completion_failed(cli, cmd, word_idx, expected, cwd=None):
- result = cli.run(
- cwd=cwd,
- env={
- "_BST_COMPLETION": "complete",
- "COMP_WORDS": cmd,
- "COMP_CWORD": str(word_idx),
- },
- )
+ result = cli.run(cwd=cwd, env={"_BST_COMPLETION": "complete", "COMP_WORDS": cmd, "COMP_CWORD": str(word_idx),},)
words = []
if result.output:
words = result.output.splitlines()
@@ -182,29 +169,14 @@ def test_option_choice(cli, cmd, word_idx, expected):
# Note that elements/ and files/ are partial completions and
# as such do not come with trailing whitespace
("bst --config ", 2, ["cache/", "elements/", "files/", "project.conf "], None),
- (
- "bst --log-file ",
- 2,
- ["cache/", "elements/", "files/", "project.conf "],
- None,
- ),
+ ("bst --log-file ", 2, ["cache/", "elements/", "files/", "project.conf "], None,),
("bst --config f", 2, ["files/"], None),
("bst --log-file f", 2, ["files/"], None),
("bst --config files", 2, ["files/bin-files/", "files/dev-files/"], None),
("bst --log-file files", 2, ["files/bin-files/", "files/dev-files/"], None),
("bst --config files/", 2, ["files/bin-files/", "files/dev-files/"], None),
- (
- "bst --log-file elements/",
- 2,
- [os.path.join("elements", e) + " " for e in PROJECT_ELEMENTS],
- None,
- ),
- (
- "bst --config ../",
- 2,
- ["../cache/", "../elements/", "../files/", "../project.conf "],
- "files",
- ),
+ ("bst --log-file elements/", 2, [os.path.join("elements", e) + " " for e in PROJECT_ELEMENTS], None,),
+ ("bst --config ../", 2, ["../cache/", "../elements/", "../files/", "../project.conf "], "files",),
(
"bst --config ../elements/",
2,
@@ -251,11 +223,7 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
"project",
"bst build com",
2,
- [
- "compose-all.bst ",
- "compose-include-bin.bst ",
- "compose-exclude-dev.bst ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
None,
),
# When running from the files subdir
@@ -264,83 +232,37 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
"project",
"bst build com",
2,
- [
- "compose-all.bst ",
- "compose-include-bin.bst ",
- "compose-exclude-dev.bst ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
"files",
),
# When passing the project directory
- (
- "project",
- "bst --directory ../ show ",
- 4,
- [e + " " for e in PROJECT_ELEMENTS],
- "files",
- ),
+ ("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 ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
"files",
),
# Also try multi arguments together
- (
- "project",
- "bst --directory ../ artifact checkout t ",
- 5,
- ["target.bst "],
- "files",
- ),
- (
- "project",
- "bst --directory ../ artifact checkout --directory ",
- 6,
- ["bin-files/", "dev-files/"],
- "files",
- ),
+ ("project", "bst --directory ../ artifact checkout t ", 5, ["target.bst "], "files",),
+ ("project", "bst --directory ../ artifact checkout --directory ", 6, ["bin-files/", "dev-files/"], "files",),
# When running in the project directory
- (
- "no-element-path",
- "bst show ",
- 2,
- [e + " " for e in PROJECT_ELEMENTS] + ["files/"],
- None,
- ),
+ ("no-element-path", "bst show ", 2, [e + " " for e in PROJECT_ELEMENTS] + ["files/"], None,),
(
"no-element-path",
"bst build com",
2,
- [
- "compose-all.bst ",
- "compose-include-bin.bst ",
- "compose-exclude-dev.bst ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
None,
),
# When running from the files subdir
- (
- "no-element-path",
- "bst show ",
- 2,
- [e + " " for e in PROJECT_ELEMENTS] + ["files/"],
- "files",
- ),
+ ("no-element-path", "bst show ", 2, [e + " " for e in PROJECT_ELEMENTS] + ["files/"], "files",),
(
"no-element-path",
"bst build com",
2,
- [
- "compose-all.bst ",
- "compose-include-bin.bst ",
- "compose-exclude-dev.bst ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
"files",
),
# When passing the project directory
@@ -352,32 +274,16 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
"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 ../ 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 ",
- ],
+ ["compose-all.bst ", "compose-include-bin.bst ", "compose-exclude-dev.bst ",],
"files",
),
# Also try multi arguments together
- (
- "no-element-path",
- "bst --directory ../ artifact checkout t ",
- 5,
- ["target.bst "],
- "files",
- ),
+ ("no-element-path", "bst --directory ../ artifact checkout t ", 5, ["target.bst "], "files",),
(
"no-element-path",
"bst --directory ../ artifact checkout --directory ",
@@ -402,18 +308,10 @@ def test_argument_element(datafiles, cli, project, cmd, word_idx, expected, subd
"project,cmd,word_idx,expected,subdir",
[
# When element has invalid suffix
- (
- "project",
- "bst --directory ../ show ",
- 4,
- [e + " " for e in MIXED_ELEMENTS],
- "files",
- )
+ ("project", "bst --directory ../ show ", 4, [e + " " for e in MIXED_ELEMENTS], "files",)
],
)
-def test_argument_element_invalid(
- datafiles, cli, project, cmd, word_idx, expected, subdir
-):
+def test_argument_element_invalid(datafiles, cli, project, cmd, word_idx, expected, subdir):
cwd = os.path.join(str(datafiles), project)
if subdir:
cwd = os.path.join(cwd, subdir)
@@ -442,9 +340,7 @@ def test_argument_artifact(cli, datafiles):
project = str(datafiles)
# Build an import element with no dependencies (as there will only be ONE cache key)
- result = cli.run(
- project=project, args=["build", "import-bin.bst"]
- ) # Has no dependencies
+ result = cli.run(project=project, args=["build", "import-bin.bst"]) # Has no dependencies
result.assert_success()
# Get the key and the artifact ref ($project/$element_name/$key)
@@ -459,23 +355,15 @@ def test_argument_artifact(cli, datafiles):
result = cli.run(
project=project,
cwd=project,
- env={
- "_BST_COMPLETION": "complete",
- "COMP_WORDS": cmd,
- "COMP_CWORD": str(word_idx),
- },
+ env={"_BST_COMPLETION": "complete", "COMP_WORDS": cmd, "COMP_CWORD": str(word_idx),},
)
if result.output:
- words = (
- result.output.splitlines()
- ) # This leaves an extra space on each e.g. ['foo.bst ']
+ words = result.output.splitlines() # This leaves an extra space on each e.g. ['foo.bst ']
words = [word.strip() for word in words]
if i == 0:
- expected = PROJECT_ELEMENTS + [
- artifact
- ] # We should now be able to see the artifact
+ expected = PROJECT_ELEMENTS + [artifact] # We should now be able to see the artifact
elif i == 1:
expected = ["target.bst", artifact]
elif i == 2: