From 76577eedd495ce41bc1b26f6fe1b4bbef71a01f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Wed, 26 Jun 2019 15:59:21 +0200 Subject: Fetch sources as needed for bst source checkout This removes the --fetch option of bst source checkout, always enabling fetch support. This is in line with fetching subprojects as needed. --- src/buildstream/_frontend/cli.py | 5 +---- src/buildstream/_stream.py | 8 ++------ tests/frontend/source_checkout.py | 15 ++++----------- tests/sourcecache/source-checkout.py | 10 ++-------- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 53adb188c..bbb9240f4 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -751,8 +751,6 @@ def source_track(app, elements, deps, except_, cross_junctions): @click.option('--deps', '-d', default='none', type=click.Choice(['build', 'none', 'run', 'all']), help='The dependencies whose sources to checkout (default: none)') -@click.option('--fetch', 'fetch_', default=False, is_flag=True, - help='Fetch elements if they are not fetched') @click.option('--tar', 'tar', default=False, is_flag=True, help='Create a tarball from the element\'s sources instead of a ' 'file tree.') @@ -760,7 +758,7 @@ def source_track(app, elements, deps, except_, cross_junctions): @click.argument('element', required=False, type=click.Path(readable=False)) @click.argument('location', type=click.Path(), required=False) @click.pass_obj -def source_checkout(app, element, location, force, deps, fetch_, except_, +def source_checkout(app, element, location, force, deps, except_, tar, build_scripts): """Checkout sources of an element to the specified location @@ -786,7 +784,6 @@ def source_checkout(app, element, location, force, deps, fetch_, except_, location=location, force=force, deps=deps, - fetch=fetch_, except_targets=except_, tar=tar, include_build_scripts=build_scripts) diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index a7db33bb9..195be55ba 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -631,14 +631,12 @@ class Stream(): # target (str): The target element whose sources to checkout # location (str): Location to checkout the sources to # deps (str): The dependencies to checkout - # fetch (bool): Whether to fetch missing sources # except_targets (list): List of targets to except from staging # def source_checkout(self, target, *, location=None, force=False, deps='none', - fetch=False, except_targets=(), tar=False, include_build_scripts=False): @@ -650,14 +648,13 @@ class Stream(): except_targets=except_targets) # Assert all sources are cached in the source dir - if fetch: - self._fetch(elements, fetch_original=True) + self._fetch(elements) self._pipeline.assert_sources_cached(elements) # Stage all sources determined by scope try: self._source_checkout(elements, location, force, deps, - fetch, tar, include_build_scripts) + tar, include_build_scripts) except BstError as e: raise StreamError("Error while writing sources" ": '{}'".format(e), detail=e.detail, reason=e.reason) from e @@ -1340,7 +1337,6 @@ class Stream(): location=None, force=False, deps='none', - fetch=False, tar=False, include_build_scripts=False): location = os.path.abspath(location) diff --git a/tests/frontend/source_checkout.py b/tests/frontend/source_checkout.py index 0bedfe1e2..38041c45d 100644 --- a/tests/frontend/source_checkout.py +++ b/tests/frontend/source_checkout.py @@ -9,7 +9,6 @@ import pytest from buildstream.testing import cli # pylint: disable=unused-import from buildstream import utils, _yaml -from buildstream._exceptions import ErrorDomain # Project directory DATA_DIR = os.path.join( @@ -145,8 +144,7 @@ def test_source_checkout_except(datafiles, cli): @pytest.mark.datafiles(DATA_DIR) -@pytest.mark.parametrize('fetch', [(False), (True)]) -def test_source_checkout_fetch(datafiles, cli, fetch): +def test_source_checkout_fetch(datafiles, cli): project = str(datafiles) checkout = os.path.join(cli.directory, 'source-checkout') target = 'remote-import-dev.bst' @@ -158,21 +156,16 @@ def test_source_checkout_fetch(datafiles, cli, fetch): 'pony.h') _yaml.dump(element, target_path) - # Testing --fetch option requires that we do not have the sources + # Testing implicit fetching requires that we do not have the sources # cached already assert cli.get_element_state(project, target) == 'fetch needed' args = ['source', 'checkout'] - if fetch: - args += ['--fetch'] args += [target, checkout] result = cli.run(project=project, args=args) - if fetch: - result.assert_success() - assert os.path.exists(os.path.join(checkout, 'remote-import-dev', 'pony.h')) - else: - result.assert_main_error(ErrorDomain.PIPELINE, 'uncached-sources') + result.assert_success() + assert os.path.exists(os.path.join(checkout, 'remote-import-dev', 'pony.h')) @pytest.mark.datafiles(DATA_DIR) diff --git a/tests/sourcecache/source-checkout.py b/tests/sourcecache/source-checkout.py index 15c80fde9..c2c7fe3cd 100644 --- a/tests/sourcecache/source-checkout.py +++ b/tests/sourcecache/source-checkout.py @@ -48,14 +48,8 @@ def test_source_checkout(tmpdir, datafiles, cli): repo = create_element_size('target.bst', project_dir, element_path, [], 100000) - # without fetch it should fail + # check implicit fetching res = cli.run(project=project_dir, args=['source', 'checkout', 'target.bst', target_dir]) - res.assert_main_error(ErrorDomain.PIPELINE, "uncached-sources") - - # fetch and check it works - res = cli.run(project=project_dir, - args=['source', 'checkout', '--fetch', 'target.bst', - target_dir]) res.assert_success() assert "Fetching from" in res.stderr @@ -75,5 +69,5 @@ def test_source_checkout(tmpdir, datafiles, cli): shutil.rmtree(os.path.join(cache_dir, 'cas')) res = cli.run(project=project_dir, - args=['source', 'checkout', '--fetch', 'target.bst', target_dir]) + args=['source', 'checkout', 'target.bst', target_dir]) res.assert_task_error(ErrorDomain.PLUGIN, None) -- cgit v1.2.1