Tiago Gomes pushed to branch tpollard/591 at BuildStream / buildstream
Commits:
-
a38d9163
by Valentin David at 2018-08-30T10:26:57Z
-
02138181
by Tristan Van Berkom at 2018-08-30T11:36:00Z
-
d23d4f3e
by Tristan Van Berkom at 2018-08-30T12:02:27Z
-
bb6aa5a5
by Tristan Van Berkom at 2018-08-30T12:27:55Z
-
680e4fe1
by knownexus at 2018-08-30T13:37:55Z
-
8cd719eb
by Phillip Smyth at 2018-08-30T15:47:06Z
-
18d0bfb4
by Tom Pollard at 2018-08-30T19:14:33Z
5 changed files:
- buildstream/_artifactcache/artifactcache.py
- buildstream/_project.py
- buildstream/_scheduler/queues/trackqueue.py
- tests/frontend/track.py
- tests/testutils/repo/bzr.py
Changes:
| ... | ... | @@ -571,7 +571,7 @@ class ArtifactCache(): |
| 571 | 571 |
def _write_cache_size(self, size):
|
| 572 | 572 |
assert isinstance(size, int)
|
| 573 | 573 |
size_file_path = os.path.join(self.context.artifactdir, CACHE_SIZE_FILE)
|
| 574 |
- with open(size_file_path, "w") as f:
|
|
| 574 |
+ with utils.save_file_atomic(size_file_path, "w") as f:
|
|
| 575 | 575 |
f.write(str(size))
|
| 576 | 576 |
|
| 577 | 577 |
# _read_cache_size()
|
| ... | ... | @@ -398,6 +398,11 @@ class Project(): |
| 398 | 398 |
"Project requested format version {}, but BuildStream {}.{} only supports up until format version {}"
|
| 399 | 399 |
.format(format_version, major, minor, BST_FORMAT_VERSION))
|
| 400 | 400 |
|
| 401 |
+ # Check if project.conf contains name key field
|
|
| 402 |
+ if self._project_conf.get('name') is None:
|
|
| 403 |
+ raise LoadError(LoadErrorReason.INVALID_DATA,
|
|
| 404 |
+ "{}: project.conf does not contain expected key '{}'".format(projectfile, 'name'))
|
|
| 405 |
+ |
|
| 401 | 406 |
# The project name, element path and option declarations
|
| 402 | 407 |
# are constant and cannot be overridden by option conditional statements
|
| 403 | 408 |
self.name = _yaml.node_get(pre_config_node, str, 'name')
|
| ... | ... | @@ -58,18 +58,9 @@ class TrackQueue(Queue): |
| 58 | 58 |
# Set the new refs in the main process one by one as they complete
|
| 59 | 59 |
for unique_id, new_ref in result:
|
| 60 | 60 |
source = _plugin_lookup(unique_id)
|
| 61 |
- try:
|
|
| 62 |
- # We appear processed if at least one source has changed
|
|
| 63 |
- if source._save_ref(new_ref):
|
|
| 64 |
- changed = True
|
|
| 65 |
- except SourceError as e:
|
|
| 66 |
- # FIXME: We currently dont have a clear path to
|
|
| 67 |
- # fail the scheduler from the main process, so
|
|
| 68 |
- # this will just warn and BuildStream will exit
|
|
| 69 |
- # with a success code.
|
|
| 70 |
- #
|
|
| 71 |
- source.warn("Failed to update project file",
|
|
| 72 |
- detail="{}".format(e))
|
|
| 61 |
+ # We appear processed if at least one source has changed
|
|
| 62 |
+ if source._save_ref(new_ref):
|
|
| 63 |
+ changed = True
|
|
| 73 | 64 |
|
| 74 | 65 |
element._tracking_done()
|
| 75 | 66 |
|
| 1 |
+import stat
|
|
| 1 | 2 |
import os
|
| 2 | 3 |
import pytest
|
| 3 | 4 |
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
|
| ... | ... | @@ -634,3 +635,36 @@ def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind): |
| 634 | 635 |
|
| 635 | 636 |
result = cli.run(project=project, args=['track', 'junction.bst'])
|
| 636 | 637 |
result.assert_success()
|
| 638 |
+ |
|
| 639 |
+ |
|
| 640 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
| 641 |
+@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
|
|
| 642 |
+def test_track_error_cannot_write_file(cli, tmpdir, datafiles, kind):
|
|
| 643 |
+ if os.geteuid() == 0:
|
|
| 644 |
+ pytest.skip("This is not testable with root permissions")
|
|
| 645 |
+ |
|
| 646 |
+ project = str(datafiles)
|
|
| 647 |
+ dev_files_path = os.path.join(project, 'files', 'dev-files')
|
|
| 648 |
+ element_path = os.path.join(project, 'elements')
|
|
| 649 |
+ element_name = 'track-test-{}.bst'.format(kind)
|
|
| 650 |
+ |
|
| 651 |
+ configure_project(project, {
|
|
| 652 |
+ 'ref-storage': 'inline'
|
|
| 653 |
+ })
|
|
| 654 |
+ |
|
| 655 |
+ repo = create_repo(kind, str(tmpdir))
|
|
| 656 |
+ ref = repo.create(dev_files_path)
|
|
| 657 |
+ |
|
| 658 |
+ element_full_path = os.path.join(element_path, element_name)
|
|
| 659 |
+ generate_element(repo, element_full_path)
|
|
| 660 |
+ |
|
| 661 |
+ st = os.stat(element_path)
|
|
| 662 |
+ try:
|
|
| 663 |
+ read_mask = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
|
|
| 664 |
+ os.chmod(element_path, stat.S_IMODE(st.st_mode) & ~read_mask)
|
|
| 665 |
+ |
|
| 666 |
+ result = cli.run(project=project, args=['track', element_name])
|
|
| 667 |
+ result.assert_main_error(ErrorDomain.STREAM, None)
|
|
| 668 |
+ result.assert_task_error(ErrorDomain.SOURCE, 'save-ref-error')
|
|
| 669 |
+ finally:
|
|
| 670 |
+ os.chmod(element_path, stat.S_IMODE(st.st_mode))
|
| ... | ... | @@ -2,6 +2,7 @@ import os |
| 2 | 2 |
import subprocess
|
| 3 | 3 |
import pytest
|
| 4 | 4 |
|
| 5 |
+from buildstream import utils
|
|
| 5 | 6 |
from .repo import Repo
|
| 6 | 7 |
from ..site import HAVE_BZR
|
| 7 | 8 |
|
| ... | ... | @@ -16,15 +17,16 @@ class Bzr(Repo): |
| 16 | 17 |
if not HAVE_BZR:
|
| 17 | 18 |
pytest.skip("bzr is not available")
|
| 18 | 19 |
super(Bzr, self).__init__(directory, subdir)
|
| 20 |
+ self.bzr = utils.get_host_tool('bzr')
|
|
| 19 | 21 |
|
| 20 | 22 |
def create(self, directory):
|
| 21 | 23 |
branch_dir = os.path.join(self.repo, 'trunk')
|
| 22 | 24 |
|
| 23 |
- subprocess.call(['bzr', 'init-repo', self.repo], env=BZR_ENV)
|
|
| 24 |
- subprocess.call(['bzr', 'init', branch_dir], env=BZR_ENV)
|
|
| 25 |
+ subprocess.call([self.bzr, 'init-repo', self.repo], env=BZR_ENV)
|
|
| 26 |
+ subprocess.call([self.bzr, 'init', branch_dir], env=BZR_ENV)
|
|
| 25 | 27 |
self.copy_directory(directory, branch_dir)
|
| 26 |
- subprocess.call(['bzr', 'add', '.'], env=BZR_ENV, cwd=branch_dir)
|
|
| 27 |
- subprocess.call(['bzr', 'commit', '--message="Initial commit"'],
|
|
| 28 |
+ subprocess.call([self.bzr, 'add', '.'], env=BZR_ENV, cwd=branch_dir)
|
|
| 29 |
+ subprocess.call([self.bzr, 'commit', '--message="Initial commit"'],
|
|
| 28 | 30 |
env=BZR_ENV, cwd=branch_dir)
|
| 29 | 31 |
|
| 30 | 32 |
return self.latest_commit()
|
| ... | ... | @@ -42,7 +44,7 @@ class Bzr(Repo): |
| 42 | 44 |
|
| 43 | 45 |
def latest_commit(self):
|
| 44 | 46 |
output = subprocess.check_output([
|
| 45 |
- 'bzr', 'version-info',
|
|
| 47 |
+ self.bzr, 'version-info',
|
|
| 46 | 48 |
'--custom', '--template={revno}',
|
| 47 | 49 |
os.path.join(self.repo, 'trunk')
|
| 48 | 50 |
], env=BZR_ENV)
|
