summaryrefslogtreecommitdiff
path: root/tests/sources/local.py
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2019-04-29 12:25:43 +0100
committerPhil Dawson <phil.dawson@codethink.co.uk>2019-04-29 12:41:43 +0100
commit0525f3dee17aeef12fe47fed4c118d4f056a7b81 (patch)
tree5c2c2c96e4c59181dbc68eff50841e117cd582fe /tests/sources/local.py
parent73ef730ed9096c6ec418176f3d903d2483262b6b (diff)
downloadbuildstream-phil/separate-local-tests.tar.gz
testing._sourcetests: Don't special case 'local' in parameter listphil/separate-local-tests
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/local.py')
-rw-r--r--tests/sources/local.py60
1 files changed, 60 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)