Tristan Van Berkom pushed to branch master 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
2 changed files:
Changes:
... | ... | @@ -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))
|