summaryrefslogtreecommitdiff
path: root/tests/sources
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2019-04-29 12:25:43 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-04-30 11:11:51 +0000
commit3cb4c23b59151c2be4d5f678bade793eba943132 (patch)
treebe58250e013428f035094d4d07627e1f15788764 /tests/sources
parent68c8df44986cf0198f95ceb45b9a248e00f31f32 (diff)
downloadbuildstream-3cb4c23b59151c2be4d5f678bade793eba943132.tar.gz
testing._sourcetests: Don't special case 'local' in parameter list
The 'local' kind is hard coded in the parameter list of on test in testing._sourcetests as so will always run regardless of what plugins have been registered. Remove this special casing by duplicating the test in the local source specific test. Ideally, the local source should have a Repo implementation and be registered with the templated tests.
Diffstat (limited to 'tests/sources')
-rw-r--r--tests/sources/local.py60
-rw-r--r--tests/sources/local/deterministic-umask/elements/base.bst5
-rw-r--r--tests/sources/local/deterministic-umask/elements/base/base-alpine.bst17
3 files changed, 82 insertions, 0 deletions
diff --git a/tests/sources/local.py b/tests/sources/local.py
index 94d45b3e9..28ed8f5fc 100644
--- a/tests/sources/local.py
+++ b/tests/sources/local.py
@@ -4,9 +4,11 @@
import os
import pytest
+from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.testing import cli # pylint: disable=unused-import
from tests.testutils import filetypegenerator
+from tests.testutils.site import HAVE_SANDBOX
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -158,3 +160,61 @@ def test_stage_directory_symlink(cli, tmpdir, datafiles):
assert os.path.exists(os.path.join(checkoutdir, 'subdir', 'anotherfile.txt'))
assert os.path.exists(os.path.join(checkoutdir, 'symlink-to-subdir', 'anotherfile.txt'))
assert os.path.islink(os.path.join(checkoutdir, 'symlink-to-subdir'))
+
+
+@pytest.mark.integration
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'deterministic-umask'))
+@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
+def test_deterministic_source_umask(cli, tmpdir, datafiles):
+
+ def create_test_file(*path, mode=0o644, content='content\n'):
+ path = os.path.join(*path)
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ with open(path, 'w') as f:
+ f.write(content)
+ os.fchmod(f.fileno(), mode)
+
+ def create_test_directory(*path, mode=0o644):
+ create_test_file(*path, '.keep', content='')
+ path = os.path.join(*path)
+ os.chmod(path, mode)
+
+ project = str(datafiles)
+ element_name = 'list.bst'
+ element_path = os.path.join(project, 'elements', element_name)
+ sourcedir = os.path.join(project, 'source')
+
+ create_test_file(sourcedir, 'a.txt', mode=0o700)
+ create_test_file(sourcedir, 'b.txt', mode=0o755)
+ create_test_file(sourcedir, 'c.txt', mode=0o600)
+ create_test_file(sourcedir, 'd.txt', mode=0o400)
+ create_test_file(sourcedir, 'e.txt', mode=0o644)
+ create_test_file(sourcedir, 'f.txt', mode=0o4755)
+ create_test_file(sourcedir, 'g.txt', mode=0o2755)
+ create_test_file(sourcedir, 'h.txt', mode=0o1755)
+ create_test_directory(sourcedir, 'dir-a', mode=0o0700)
+ create_test_directory(sourcedir, 'dir-c', mode=0o0755)
+ create_test_directory(sourcedir, 'dir-d', mode=0o4755)
+ create_test_directory(sourcedir, 'dir-e', mode=0o2755)
+ create_test_directory(sourcedir, 'dir-f', mode=0o1755)
+
+ source = {'kind': 'local',
+ 'path': 'source'}
+ element = {
+ 'kind': 'manual',
+ 'depends': [
+ {
+ 'filename': 'base.bst',
+ 'type': 'build'
+ }
+ ],
+ 'sources': [
+ source
+ ],
+ 'config': {
+ 'install-commands': [
+ 'ls -l >"%{install-root}/ls-l"'
+ ]
+ }
+ }
+ _yaml.dump(element, element_path)
diff --git a/tests/sources/local/deterministic-umask/elements/base.bst b/tests/sources/local/deterministic-umask/elements/base.bst
new file mode 100644
index 000000000..428afa736
--- /dev/null
+++ b/tests/sources/local/deterministic-umask/elements/base.bst
@@ -0,0 +1,5 @@
+# elements/base.bst
+
+kind: stack
+depends:
+ - base/base-alpine.bst
diff --git a/tests/sources/local/deterministic-umask/elements/base/base-alpine.bst b/tests/sources/local/deterministic-umask/elements/base/base-alpine.bst
new file mode 100644
index 000000000..c5833095d
--- /dev/null
+++ b/tests/sources/local/deterministic-umask/elements/base/base-alpine.bst
@@ -0,0 +1,17 @@
+kind: import
+
+description: |
+ Alpine Linux base for tests
+
+ Generated using the `tests/integration-tests/base/generate-base.sh` script.
+
+sources:
+ - kind: tar
+ base-dir: ''
+ (?):
+ - arch == "x86-64":
+ ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
+ url: "alpine:integration-tests-base.v1.x86_64.tar.xz"
+ - arch == "aarch64":
+ ref: 431fb5362032ede6f172e70a3258354a8fd71fcbdeb1edebc0e20968c792329a
+ url: "alpine:integration-tests-base.v1.aarch64.tar.xz"