summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWilliam Salmon <will.salmon@codethink.co.uk>2018-09-10 15:46:46 +0100
committerWilliam Salmon <will.salmon@codethink.co.uk>2019-01-03 13:01:29 +0000
commit61dc4f251138ebdf52c581ac52534dd3ee8e4205 (patch)
tree91e2beb8c3d71649da8865d9e68bcec6198ecab9 /tests
parent14da6955f9dd7ed820992a49af3eda8fe8092890 (diff)
downloadbuildstream-61dc4f251138ebdf52c581ac52534dd3ee8e4205.tar.gz
Adding Out of Source Build Examplewillsalmon/outOfSourecBuilddocs
For issue #695 in Gitlab.
Diffstat (limited to 'tests')
-rw-r--r--tests/examples/out-of-source.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/examples/out-of-source.py b/tests/examples/out-of-source.py
new file mode 100644
index 000000000..6f6842175
--- /dev/null
+++ b/tests/examples/out-of-source.py
@@ -0,0 +1,78 @@
+import os
+import pytest
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+from tests.testutils.site import HAVE_BWRAP, IS_LINUX
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples', 'out-of-source-build'
+)
+
+
+# Tests a build of the autotools amhello project on a alpine-linux base runtime
+@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
+@pytest.mark.datafiles(DATA_DIR)
+def test_project_build_projcet(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+
+ # Check that the project can be built correctly.
+ result = cli.run(project=project, args=['build', 'sourceroot.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['checkout', 'sourceroot.bst', checkout])
+ result.assert_success()
+
+ assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
+ '/usr/share',
+ '/bin/hello_buildstream'])
+
+
+# Tests a build of the autotools amhello project on a alpine-linux base runtime
+@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
+@pytest.mark.datafiles(DATA_DIR)
+def test_project_build_main(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+
+ # Check that the project can be built correctly.
+ result = cli.run(project=project, args=['build', 'subfolder.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['checkout', 'subfolder.bst', checkout])
+ result.assert_success()
+
+ assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
+ '/usr/share',
+ '/bin/hello_buildstream'])
+
+
+# Test running an executable built with autotools.
+@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
+@pytest.mark.datafiles(DATA_DIR)
+def test_run_project(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ result = cli.run(project=project, args=['build', 'sourceroot.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['shell', 'sourceroot.bst', 'hello_buildstream'])
+ result.assert_success()
+ assert result.output == 'Hello, World! Built from the source root.\n'
+
+
+# Test running an executable built with autotools.
+@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
+@pytest.mark.datafiles(DATA_DIR)
+def test_run_main(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ result = cli.run(project=project, args=['build', 'subfolder.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['shell', 'subfolder.bst', 'hello_buildstream'])
+ result.assert_success()
+ assert result.output == 'Hello, World! Built from a subdirectory of the source.\n'