summaryrefslogtreecommitdiff
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
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.
-rw-r--r--buildstream/testing/_sourcetests/source_determinism.py12
-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
4 files changed, 86 insertions, 8 deletions
diff --git a/buildstream/testing/_sourcetests/source_determinism.py b/buildstream/testing/_sourcetests/source_determinism.py
index 8597a7072..3a5c264d9 100644
--- a/buildstream/testing/_sourcetests/source_determinism.py
+++ b/buildstream/testing/_sourcetests/source_determinism.py
@@ -48,7 +48,7 @@ def create_test_directory(*path, mode=0o644):
@pytest.mark.integration
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("kind", ['local', *ALL_REPO_KINDS])
+@pytest.mark.parametrize("kind", [*ALL_REPO_KINDS])
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_deterministic_source_umask(cli, tmpdir, datafiles, kind):
project = str(datafiles)
@@ -71,13 +71,9 @@ def test_deterministic_source_umask(cli, tmpdir, datafiles, kind):
create_test_directory(sourcedir, 'dir-e', mode=0o2755)
create_test_directory(sourcedir, 'dir-f', mode=0o1755)
- if kind == 'local':
- source = {'kind': 'local',
- 'path': 'source'}
- else:
- repo = create_repo(kind, repodir)
- ref = repo.create(sourcedir)
- source = repo.source_config(ref=ref)
+ repo = create_repo(kind, repodir)
+ ref = repo.create(sourcedir)
+ source = repo.source_config(ref=ref)
element = {
'kind': 'manual',
'depends': [
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"