Jürg Billeter pushed to branch juerg/python3.7 at BuildStream / buildstream
Commits:
-
42aa3999
by William Salmon at 2018-08-07T13:41:02Z
-
2ceb5dec
by Will Salmon at 2018-08-07T14:46:36Z
-
eee4b674
by Jürg Billeter at 2018-08-07T15:36:35Z
-
ea27e389
by Jürg Billeter at 2018-08-07T15:36:35Z
5 changed files:
- buildstream/_artifactcache/cascache.py
- buildstream/_pipeline.py
- buildstream/plugins/sources/git.py
- setup.py
- tests/sources/git.py
Changes:
| ... | ... | @@ -846,6 +846,9 @@ class _CASRemote(): |
| 846 | 846 |
|
| 847 | 847 |
|
| 848 | 848 |
def _grouper(iterable, n):
|
| 849 |
- # pylint: disable=stop-iteration-return
|
|
| 850 | 849 |
while True:
|
| 851 |
- yield itertools.chain([next(iterable)], itertools.islice(iterable, n - 1))
|
|
| 850 |
+ try:
|
|
| 851 |
+ current = next(iterable)
|
|
| 852 |
+ except StopIteration:
|
|
| 853 |
+ return
|
|
| 854 |
+ yield itertools.chain([current], itertools.islice(iterable, n - 1))
|
| ... | ... | @@ -358,10 +358,24 @@ class Pipeline(): |
| 358 | 358 |
inconsistent.append(element)
|
| 359 | 359 |
|
| 360 | 360 |
if inconsistent:
|
| 361 |
- detail = "Exact versions are missing for the following elements\n" + \
|
|
| 362 |
- "Try tracking these elements first with `bst track`\n\n"
|
|
| 361 |
+ detail = "Exact versions are missing for the following elements:\n\n"
|
|
| 362 |
+ |
|
| 363 |
+ missingTrack = 0
|
|
| 363 | 364 |
for element in inconsistent:
|
| 364 |
- detail += " " + element._get_full_name() + "\n"
|
|
| 365 |
+ detail += " " + element._get_full_name()
|
|
| 366 |
+ for source in element.sources():
|
|
| 367 |
+ if not source._get_consistency() and not source.get_ref():
|
|
| 368 |
+ if hasattr(source, 'tracking') and source.tracking is None:
|
|
| 369 |
+ detail += ": Source {} is missing ref and track. ".format(source._get_full_name()) + \
|
|
| 370 |
+ "Please specify a ref or branch/tag to track."
|
|
| 371 |
+ missingTrack = 1
|
|
| 372 |
+ |
|
| 373 |
+ detail += "\n"
|
|
| 374 |
+ |
|
| 375 |
+ if missingTrack:
|
|
| 376 |
+ detail += "\nThen track these elements with `bst track`\n"
|
|
| 377 |
+ else:
|
|
| 378 |
+ detail += "\nTry tracking these elements first with `bst track`\n"
|
|
| 365 | 379 |
raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline")
|
| 366 | 380 |
|
| 367 | 381 |
#############################################################
|
| ... | ... | @@ -363,6 +363,12 @@ class GitSource(Source): |
| 363 | 363 |
|
| 364 | 364 |
# If self.tracking is not specified it's not an error, just silently return
|
| 365 | 365 |
if not self.tracking:
|
| 366 |
+ # Is there a better way to check if a ref is given.
|
|
| 367 |
+ if self.mirror.ref is None:
|
|
| 368 |
+ detail = 'Without a tracking branch ref can not be updated. Please ' + \
|
|
| 369 |
+ 'provide a ref or a track.'
|
|
| 370 |
+ raise SourceError("{}: No track or ref".format(self),
|
|
| 371 |
+ detail=detail, reason="track-attempt-no-track")
|
|
| 366 | 372 |
return None
|
| 367 | 373 |
|
| 368 | 374 |
with self.timed_activity("Tracking {} from {}"
|
| ... | ... | @@ -272,6 +272,5 @@ setup(name='BuildStream', |
| 272 | 272 |
'pytest-cov >= 2.5.0',
|
| 273 | 273 |
# Provide option to run tests in parallel, less reliable
|
| 274 | 274 |
'pytest-xdist',
|
| 275 |
- 'pytest >= 3.1.0',
|
|
| 276 |
- 'pylint >= 1.8 , < 2'],
|
|
| 275 |
+ 'pytest >= 3.1.0'],
|
|
| 277 | 276 |
zip_safe=False)
|
| ... | ... | @@ -359,3 +359,45 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): |
| 359 | 359 |
|
| 360 | 360 |
# Assert that we are just fine without it, and emit a warning to the user.
|
| 361 | 361 |
assert "Ignoring inconsistent submodule" in result.stderr
|
| 362 |
+ |
|
| 363 |
+ |
|
| 364 |
+@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
|
|
| 365 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
|
|
| 366 |
+def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles):
|
|
| 367 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
| 368 |
+ |
|
| 369 |
+ # Create the repo from 'repofiles' subdir
|
|
| 370 |
+ repo = create_repo('git', str(tmpdir))
|
|
| 371 |
+ ref = repo.create(os.path.join(project, 'repofiles'))
|
|
| 372 |
+ |
|
| 373 |
+ # Write out our test target
|
|
| 374 |
+ gitsource = repo.source_config(ref=None)
|
|
| 375 |
+ gitsource.pop('track')
|
|
| 376 |
+ element = {
|
|
| 377 |
+ 'kind': 'import',
|
|
| 378 |
+ 'sources': [
|
|
| 379 |
+ gitsource
|
|
| 380 |
+ ]
|
|
| 381 |
+ }
|
|
| 382 |
+ |
|
| 383 |
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
| 384 |
+ |
|
| 385 |
+ # Track will encounter an inconsistent submodule without any ref
|
|
| 386 |
+ result = cli.run(project=project, args=['track', 'target.bst'])
|
|
| 387 |
+ result.assert_main_error(ErrorDomain.STREAM, None)
|
|
| 388 |
+ result.assert_task_error(ErrorDomain.SOURCE, 'track-attempt-no-track')
|
|
| 389 |
+ |
|
| 390 |
+ # Assert that we are just fine without it, and emit a warning to the user.
|
|
| 391 |
+ assert "FAILURE git source at" in result.stderr
|
|
| 392 |
+ assert "Without a tracking branch ref can not be updated. Please " + \
|
|
| 393 |
+ "provide a ref or a track." in result.stderr
|
|
| 394 |
+ |
|
| 395 |
+ # Track will encounter an inconsistent submodule without any ref
|
|
| 396 |
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
| 397 |
+ result.assert_main_error(ErrorDomain.PIPELINE, 'inconsistent-pipeline')
|
|
| 398 |
+ result.assert_task_error(None, None)
|
|
| 399 |
+ |
|
| 400 |
+ # Assert that we are just fine without it, and emit a warning to the user.
|
|
| 401 |
+ assert "Exact versions are missing for the following elements" in result.stderr
|
|
| 402 |
+ assert "is missing ref and track." in result.stderr
|
|
| 403 |
+ assert "Then track these elements with `bst track`" in result.stderr
|
