diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2019-05-10 08:15:35 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2019-05-10 08:15:35 +0000 |
commit | 34268dd10146c4cf0dd3e5c4b580a2a583e9edec (patch) | |
tree | 02151da8ccc92b7011b999872ae97baf46d7f4df | |
parent | 879dca35de4c09a3c05f671ba8cca1aeeb958996 (diff) | |
parent | 627502a63ab1e1cf1e878d33b9983df88f01e03f (diff) | |
download | buildstream-34268dd10146c4cf0dd3e5c4b580a2a583e9edec.tar.gz |
Merge branch 'tristan/fix-build-track-all-no-strict-1.2' into 'bst-1.2'
Fix build track all no strict 1.2
See merge request BuildStream/buildstream!1331
-rw-r--r-- | buildstream/element.py | 4 | ||||
-rw-r--r-- | tests/frontend/buildtrack.py | 95 |
2 files changed, 95 insertions, 4 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index b98675720..3bdf601c1 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2568,9 +2568,11 @@ class Element(Plugin): element = queue.pop() old_ready_for_runtime = element.__ready_for_runtime + old_strict_cache_key = element.__strict_cache_key element._update_state() - if element.__ready_for_runtime != old_ready_for_runtime: + if element.__ready_for_runtime != old_ready_for_runtime or \ + element.__strict_cache_key != old_strict_cache_key: for rdep in element.__reverse_dependencies: queue.push(rdep._unique_id, rdep) diff --git a/tests/frontend/buildtrack.py b/tests/frontend/buildtrack.py index 3f0a3adbe..d821f18e4 100644 --- a/tests/frontend/buildtrack.py +++ b/tests/frontend/buildtrack.py @@ -4,7 +4,7 @@ import shutil import itertools import pytest -from tests.testutils import cli, create_repo +from tests.testutils import cli, create_repo, generate_junction from buildstream import _yaml from buildstream._exceptions import ErrorDomain @@ -30,6 +30,7 @@ def create_element(repo, name, path, dependencies, ref=None): @pytest.mark.datafiles(os.path.join(DATA_DIR)) +@pytest.mark.parametrize("strict", [True, False], ids=["strict", "no-strict"]) @pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) @pytest.mark.parametrize("track_targets,exceptions,tracked", [ # Test with no exceptions @@ -47,7 +48,7 @@ def create_element(repo, name, path, dependencies, ref=None): (['3.bst'], ['2.bst', '3.bst'], []), (['2.bst', '3.bst'], ['2.bst', '3.bst'], []) ]) -def test_build_track(cli, datafiles, tmpdir, ref_storage, +def test_build_track(cli, datafiles, tmpdir, ref_storage, strict, track_targets, exceptions, tracked): project = os.path.join(datafiles.dirname, datafiles.basename) dev_files_path = os.path.join(project, 'files', 'dev-files') @@ -59,6 +60,13 @@ def test_build_track(cli, datafiles, tmpdir, ref_storage, configure_project(project, { 'ref-storage': ref_storage }) + cli.configure({ + 'projects': { + 'test': { + 'strict': strict + } + } + }) create_elements = { '0.bst': [ @@ -115,8 +123,13 @@ def test_build_track(cli, datafiles, tmpdir, ref_storage, args += ['0.bst'] result = cli.run(project=project, silent=True, args=args) - tracked_elements = result.get_tracked_elements() + result.assert_success() + # Assert that the main target 0.bst is cached + assert cli.get_element_state(project, '0.bst') == 'cached' + + # Assert that we tracked exactly the elements we expected to + tracked_elements = result.get_tracked_elements() assert set(tracked_elements) == set(tracked) # Delete element sources @@ -137,6 +150,82 @@ def test_build_track(cli, datafiles, tmpdir, ref_storage, assert not os.path.exists(os.path.join(project, 'project.refs')) +# This tests a very specific scenario: +# +# o Local cache is empty +# o Strict mode is disabled +# o The build target has only build dependencies +# o The build is launched with --track-all +# +# In this scenario, we have encountered bugs where BuildStream returns +# successfully after tracking completes without ever pulling, fetching or +# building anything. +# +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("strict", [True, False], ids=["strict", "no-strict"]) +@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')]) +def test_build_track_all(cli, tmpdir, datafiles, strict, ref_storage): + project = os.path.join(datafiles.dirname, datafiles.basename) + subproject_path = os.path.join(project, 'files', 'sub-project') + subproject_element_path = os.path.join(project, 'files', 'sub-project', 'elements') + junction_path = os.path.join(project, 'elements', 'junction.bst') + element_path = os.path.join(project, 'elements') + dev_files_path = os.path.join(project, 'files', 'dev-files') + + configure_project(project, { + 'ref-storage': ref_storage + }) + cli.configure({ + 'projects': { + 'test': { + 'strict': strict + } + } + }) + + # We need a repo for real trackable elements + repo = create_repo('git', str(tmpdir)) + ref = repo.create(dev_files_path) + + # Create a trackable element to depend on the cross junction element, + # this one has it's ref resolved already + create_element(repo, 'sub-target.bst', subproject_element_path, ['import-etc.bst'], ref=ref) + + # Create a trackable element to depend on the cross junction element + create_element(repo, 'target.bst', element_path, [ + { + 'junction': 'junction.bst', + 'filename': 'sub-target.bst' + } + ]) + + # Create a repo to hold the subproject and generate a junction element for it + generate_junction(tmpdir, subproject_path, junction_path, store_ref=False) + + # Now create a compose element at the top level + element = { + 'kind': 'compose', + 'depends': [ + { + 'filename': 'target.bst', + 'type': 'build' + } + ] + } + _yaml.dump(element, os.path.join(element_path, 'composed.bst')) + + # Track the junction itself first. + result = cli.run(project=project, args=['track', 'junction.bst']) + result.assert_success() + + # Build it with --track-all + result = cli.run(project=project, silent=True, args=['build', '--track-all', 'composed.bst']) + result.assert_success() + + # Assert that the main target is cached as a result + assert cli.get_element_state(project, 'composed.bst') == 'cached' + + @pytest.mark.datafiles(os.path.join(DATA_DIR)) @pytest.mark.parametrize("track_targets,exceptions,tracked", [ # Test with no exceptions |