summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2018-02-23 17:25:25 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-04-23 13:37:06 +0000
commit3ec1cab15db686a77240b3d30d238c66be505a81 (patch)
treea22e905ee44a43c1bbd406754d6e4db8f4265c77
parentcb10e2bde71af025eb2f79d24b40a02c718a3c5e (diff)
downloadbuildstream-3ec1cab15db686a77240b3d30d238c66be505a81.tar.gz
Add compose-symlinks testcase
This is a regression test for the issue raised here: https://gitlab.com/BuildStream/buildstream/issues/270
-rw-r--r--tests/integration/compose-symlinks.py43
-rw-r--r--tests/integration/project/elements/compose-symlinks/base.bst5
-rw-r--r--tests/integration/project/elements/compose-symlinks/compose.bst11
-rw-r--r--tests/integration/project/elements/compose-symlinks/overlay.bst5
-rw-r--r--tests/integration/project/files/compose-symlinks/base/usr/sbin/dummy1
-rw-r--r--tests/integration/project/files/compose-symlinks/overlay/sbin/init1
6 files changed, 66 insertions, 0 deletions
diff --git a/tests/integration/compose-symlinks.py b/tests/integration/compose-symlinks.py
new file mode 100644
index 000000000..bf279fa6f
--- /dev/null
+++ b/tests/integration/compose-symlinks.py
@@ -0,0 +1,43 @@
+import io
+import os
+import sys
+import pytest
+
+from buildstream import _yaml
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import walk_dir
+
+
+pytestmark = pytest.mark.integration
+
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "project"
+)
+
+
+# Test that staging a file inside a directory symlink works as expected.
+#
+# Regression test for https://gitlab.com/BuildStream/buildstream/issues/270
+@pytest.mark.datafiles(DATA_DIR)
+def test_compose_symlinks(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+ element_path = os.path.join(project, 'elements')
+
+ # Symlinks do not survive being placed in a source distribution
+ # ('setup.py sdist'), so we have to create the one we need here.
+ project_files = os.path.join(project, 'files', 'compose-symlinks', 'base')
+ symlink_file = os.path.join(project_files, 'sbin')
+ os.symlink(os.path.join('usr', 'sbin'), symlink_file, target_is_directory=True)
+
+ result = cli.run(project=project, args=['build', 'compose-symlinks/compose.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['checkout', 'compose-symlinks/compose.bst', checkout])
+ result.assert_success()
+
+ assert set(walk_dir(checkout)) == set(['/sbin', '/usr', '/usr/sbin',
+ '/usr/sbin/init', '/usr/sbin/dummy'])
diff --git a/tests/integration/project/elements/compose-symlinks/base.bst b/tests/integration/project/elements/compose-symlinks/base.bst
new file mode 100644
index 000000000..31fd9c322
--- /dev/null
+++ b/tests/integration/project/elements/compose-symlinks/base.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+ path: files/compose-symlinks/base
diff --git a/tests/integration/project/elements/compose-symlinks/compose.bst b/tests/integration/project/elements/compose-symlinks/compose.bst
new file mode 100644
index 000000000..853a8575b
--- /dev/null
+++ b/tests/integration/project/elements/compose-symlinks/compose.bst
@@ -0,0 +1,11 @@
+kind: compose
+
+depends:
+- filename: compose-symlinks/base.bst
+ type: build
+- filename: compose-symlinks/overlay.bst
+ type: build
+
+config:
+ include:
+ - runtime
diff --git a/tests/integration/project/elements/compose-symlinks/overlay.bst b/tests/integration/project/elements/compose-symlinks/overlay.bst
new file mode 100644
index 000000000..67e01caf6
--- /dev/null
+++ b/tests/integration/project/elements/compose-symlinks/overlay.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+ path: files/compose-symlinks/overlay
diff --git a/tests/integration/project/files/compose-symlinks/base/usr/sbin/dummy b/tests/integration/project/files/compose-symlinks/base/usr/sbin/dummy
new file mode 100644
index 000000000..421376db9
--- /dev/null
+++ b/tests/integration/project/files/compose-symlinks/base/usr/sbin/dummy
@@ -0,0 +1 @@
+dummy
diff --git a/tests/integration/project/files/compose-symlinks/overlay/sbin/init b/tests/integration/project/files/compose-symlinks/overlay/sbin/init
new file mode 100644
index 000000000..257cc5642
--- /dev/null
+++ b/tests/integration/project/files/compose-symlinks/overlay/sbin/init
@@ -0,0 +1 @@
+foo