summaryrefslogtreecommitdiff
path: root/tests/sources/remote.py
diff options
context:
space:
mode:
authorEd Baunton <ebaunton1@bloomberg.net>2018-07-27 14:01:57 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-08-07 05:04:50 +0000
commit3d26ff6eff05648afdc3188175bd327c6f1676b1 (patch)
treede7476601a128b15051a9a6de2695bbb952fe46d /tests/sources/remote.py
parenta8073264fb5e50090d64a8ad8acbb1ef64fda2f1 (diff)
downloadbuildstream-3d26ff6eff05648afdc3188175bd327c6f1676b1.tar.gz
remote.py: Add support for marking downloaded files executable
Add an optional flag to make files executable after having downloaded them. Instead of leaving the permissioning of downloaded file in remote.py up to the user's umask; expressly set permissions to 0644 or 0755 if executable. Bump format version to 13.
Diffstat (limited to 'tests/sources/remote.py')
-rw-r--r--tests/sources/remote.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/sources/remote.py b/tests/sources/remote.py
index b7c8c08cf..d3968395f 100644
--- a/tests/sources/remote.py
+++ b/tests/sources/remote.py
@@ -1,4 +1,5 @@
import os
+import stat
import pytest
from buildstream._exceptions import ErrorDomain
@@ -82,7 +83,14 @@ def test_simple_file_build(cli, tmpdir, datafiles):
result.assert_success()
# Note that the url of the file in target.bst is actually /dir/file
# but this tests confirms we take the basename
- assert(os.path.exists(os.path.join(checkoutdir, 'file')))
+ checkout_file = os.path.join(checkoutdir, 'file')
+ assert(os.path.exists(checkout_file))
+
+ mode = os.stat(checkout_file).st_mode
+ # Assert not executable by anyone
+ assert(not (mode & (stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)))
+ # Assert not writeable by anyone other than me
+ assert(not (mode & (stat.S_IWGRP | stat.S_IWOTH)))
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'single-file-custom-name'))
@@ -119,6 +127,7 @@ def test_unique_key(cli, tmpdir, datafiles):
generate_project(project, tmpdir)
assert cli.get_element_state(project, 'target.bst') == "fetch needed"
assert cli.get_element_state(project, 'target-custom.bst') == "fetch needed"
+ assert cli.get_element_state(project, 'target-custom-executable.bst') == "fetch needed"
# Try to fetch it
result = cli.run(project=project, args=[
'fetch', 'target.bst'
@@ -127,7 +136,31 @@ def test_unique_key(cli, tmpdir, datafiles):
# We should download the file only once
assert cli.get_element_state(project, 'target.bst') == 'buildable'
assert cli.get_element_state(project, 'target-custom.bst') == 'buildable'
+ assert cli.get_element_state(project, 'target-custom-executable.bst') == 'buildable'
# But the cache key is different because the 'filename' is different.
assert cli.get_element_key(project, 'target.bst') != \
- cli.get_element_key(project, 'target-custom.bst')
+ cli.get_element_key(project, 'target-custom.bst') != \
+ cli.get_element_key(project, 'target-custom-executable.bst')
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'unique-keys'))
+def test_executable(cli, tmpdir, datafiles):
+ '''This test confirms that the 'ecxecutable' parameter is honoured.
+ '''
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ generate_project(project, tmpdir)
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+ assert cli.get_element_state(project, 'target-custom-executable.bst') == "fetch needed"
+ # Try to fetch it
+ result = cli.run(project=project, args=[
+ 'build', 'target-custom-executable.bst'
+ ])
+
+ result = cli.run(project=project, args=[
+ 'checkout', 'target-custom-executable.bst', checkoutdir
+ ])
+ mode = os.stat(os.path.join(checkoutdir, 'some-custom-file')).st_mode
+ assert (mode & stat.S_IEXEC)
+ # Assert executable by anyone
+ assert(mode & (stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH))