summaryrefslogtreecommitdiff
path: root/tests/integration/shell.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-24 18:27:08 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-25 00:34:39 +0900
commit0d5ba30e9a917d9f574f0c468678148136a7f2e5 (patch)
tree6dd52f4dfb2c22d206734ba9c80f55d91b59bc67 /tests/integration/shell.py
parentc5448d1400aa70ae7fd4281d2c855e89686f1200 (diff)
downloadbuildstream-0d5ba30e9a917d9f574f0c468678148136a7f2e5.tar.gz
tests/integration/shell.py: Dont use shlex, use command vectors
Using shlex messes with the argv we want to pass to a shell, this was not working for the newly added test which passes "${var}" strings as arguments to the shell. Also, removed a redundant line to explicitly build something in the 'no_shell' test; that is taken care of by the helper.
Diffstat (limited to 'tests/integration/shell.py')
-rw-r--r--tests/integration/shell.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index 6a66b7e4d..7e9c5afd3 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -1,5 +1,4 @@
import os
-import shlex
import pytest
from buildstream import _yaml
@@ -16,13 +15,23 @@ DATA_DIR = os.path.join(
)
-def execute_shell(cli, project, string, element='base.bst'):
+# execute_shell()
+#
+# Helper to run `bst shell` and first ensure that the element is built
+#
+# Args:
+# cli (Cli): The cli runner fixture
+# project (str): The project directory
+# command (list): The command argv list
+# element (str): The element to build and run a shell with
+#
+def execute_shell(cli, project, command, element='base.bst'):
# Ensure the element is built
result = cli.run(project=project, args=['build', element])
assert result.exit_code == 0
return cli.run(project=project,
- args=['shell', element, '--'] + shlex.split(string))
+ args=['shell', element, '--'] + command)
# Test running something through a shell, allowing it to find the
@@ -31,7 +40,7 @@ def execute_shell(cli, project, string, element='base.bst'):
def test_shell(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
- result = execute_shell(cli, project, "echo Ponies!")
+ result = execute_shell(cli, project, ["echo", "Ponies!"])
assert result.exit_code == 0
assert result.output == "Ponies!\n"
@@ -41,7 +50,7 @@ def test_shell(cli, tmpdir, datafiles):
def test_executable(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
- result = execute_shell(cli, project, "/bin/echo Horseys!")
+ result = execute_shell(cli, project, ["/bin/echo", "Horseys!"])
assert result.exit_code == 0
assert result.output == "Horseys!\n"
@@ -73,9 +82,6 @@ def test_no_shell(cli, tmpdir, datafiles):
os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True)
_yaml.dump(element, os.path.join(element_path, element_name))
- result = cli.run(project=project, args=['build', element_name])
- assert result.exit_code == 0
-
- result = execute_shell(cli, project, '/bin/echo Pegasissies!', element=element_name)
+ result = execute_shell(cli, project, ['/bin/echo', 'Pegasissies!'], element=element_name)
assert result.exit_code == 0
assert result.output == "Pegasissies!\n"