summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-11 17:44:22 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-11 18:42:56 +0900
commita1564c4a1cf077b1a8537d37e19d1748a0905b20 (patch)
tree0d3996dde207ad3fab82af934fec36aa6df27ced
parentd46fbbcbfec7f44cfa3d412b70000eff633b85bb (diff)
downloadbuildstream-a1564c4a1cf077b1a8537d37e19d1748a0905b20.tar.gz
tests/integration/shell.py: Test that workspaced files are visible in a bst shell
Test both in regular `bst shell --build`, and on a failed build sysroot with `bst shell --sysroot`, the latter being the semantic used when debugging a failed build. This guards against regressions of issue #346
-rw-r--r--tests/integration/project/elements/workspace/workspace-mount-fail.bst14
-rw-r--r--tests/integration/shell.py77
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/integration/project/elements/workspace/workspace-mount-fail.bst b/tests/integration/project/elements/workspace/workspace-mount-fail.bst
new file mode 100644
index 000000000..d4cd5d26a
--- /dev/null
+++ b/tests/integration/project/elements/workspace/workspace-mount-fail.bst
@@ -0,0 +1,14 @@
+kind: manual
+description: Workspace mount test
+
+depends:
+ - filename: base.bst
+
+sources:
+ - kind: local
+ path: files/workspace-mount-src/
+
+config:
+ build-commands:
+ - cc -c hello.c
+ - exit 1
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index e2a4740bf..844f51d62 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -2,6 +2,7 @@ import os
import pytest
from buildstream import _yaml
+from buildstream._exceptions import ErrorDomain
from tests.testutils import cli_integration as cli
@@ -265,3 +266,79 @@ def test_cli_mount(cli, tmpdir, datafiles, path):
result = execute_shell(cli, project, ['cat', path], mount=(ponyfile, path))
assert result.exit_code == 0
assert result.output == 'pony\n'
+
+
+# Test that we can see the workspace files in a shell
+@pytest.mark.integration
+@pytest.mark.datafiles(DATA_DIR)
+def test_workspace_visible(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ workspace = os.path.join(cli.directory, 'workspace')
+ element_name = 'workspace/workspace-mount-fail.bst'
+
+ # Open a workspace on our build failing element
+ #
+ res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
+ assert res.exit_code == 0
+
+ # Ensure the dependencies of our build failing element are built
+ result = cli.run(project=project, args=['build', 'base.bst'])
+ assert result.exit_code == 0
+
+ # Obtain a copy of the hello.c content from the workspace
+ #
+ workspace_hello_path = os.path.join(cli.directory, 'workspace', 'hello.c')
+ assert os.path.exists(workspace_hello_path)
+ with open(workspace_hello_path, 'r') as f:
+ workspace_hello = f.read()
+
+ # Cat the hello.c file from a bst shell command, and assert
+ # that we got the same content here
+ #
+ result = cli.run(project=project, args=[
+ 'shell', '--build', element_name, '--', 'cat', 'hello.c'
+ ])
+ assert result.exit_code == 0
+ assert result.output == workspace_hello
+
+
+# Test that we can see the workspace files in a shell
+@pytest.mark.integration
+@pytest.mark.datafiles(DATA_DIR)
+def test_sysroot_workspace_visible(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ workspace = os.path.join(cli.directory, 'workspace')
+ element_name = 'workspace/workspace-mount-fail.bst'
+
+ # Open a workspace on our build failing element
+ #
+ res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
+ assert res.exit_code == 0
+
+ # Ensure the dependencies of our build failing element are built
+ result = cli.run(project=project, args=['build', element_name])
+ result.assert_main_error(ErrorDomain.PIPELINE, None)
+
+ # Discover the sysroot of the failed build directory, after one
+ # failed build, there should be only one directory there.
+ #
+ build_base = os.path.join(cli.directory, 'build')
+ build_dirs = os.listdir(path=build_base)
+ assert len(build_dirs) == 1
+ build_dir = os.path.join(build_base, build_dirs[0])
+
+ # Obtain a copy of the hello.c content from the workspace
+ #
+ workspace_hello_path = os.path.join(cli.directory, 'workspace', 'hello.c')
+ assert os.path.exists(workspace_hello_path)
+ with open(workspace_hello_path, 'r') as f:
+ workspace_hello = f.read()
+
+ # Cat the hello.c file from a bst shell command, and assert
+ # that we got the same content here
+ #
+ result = cli.run(project=project, args=[
+ 'shell', '--build', '--sysroot', build_dir, element_name, '--', 'cat', 'hello.c'
+ ])
+ assert result.exit_code == 0
+ assert result.output == workspace_hello