Skip to content
Snippets Groups Projects
Commit 650c4d8d authored by Valentin David's avatar Valentin David
Browse files

Merge branch 'valentindavid/fix_included_junction_track-1.2' into 'bst-1.2'

Fix tracking of junctions used in project.conf.

See merge request !645
parents e5dfbb54 2b5c63d0
No related branches found
No related tags found
1 merge request!645Fix tracking of junctions used in project.conf.
Pipeline #27784393 passed
...@@ -267,8 +267,11 @@ class Stream(): ...@@ -267,8 +267,11 @@ class Stream():
except_targets=None, except_targets=None,
cross_junctions=False): cross_junctions=False):
# We pass no target to build. Only to track. Passing build targets
# would fully load project configuration which might not be
# possible before tracking is done.
_, elements = \ _, elements = \
self._load(targets, targets, self._load([], targets,
selection=selection, track_selection=selection, selection=selection, track_selection=selection,
except_targets=except_targets, except_targets=except_targets,
track_except_targets=except_targets, track_except_targets=except_targets,
...@@ -817,6 +820,12 @@ class Stream(): ...@@ -817,6 +820,12 @@ class Stream():
# #
# A convenience method for loading element lists # A convenience method for loading element lists
# #
# If `targets` is not empty used project configuration will be
# fully loaded. If `targets` is empty, tracking will still be
# resolved for elements in `track_targets`, but no build pipeline
# will be resolved. This is behavior is import for track() to
# not trigger full loading of project configuration.
#
# Args: # Args:
# targets (list of str): Main targets to load # targets (list of str): Main targets to load
# track_targets (list of str): Tracking targets # track_targets (list of str): Tracking targets
...@@ -864,7 +873,7 @@ class Stream(): ...@@ -864,7 +873,7 @@ class Stream():
# #
# This can happen with `bst build --track` # This can happen with `bst build --track`
# #
if not self._pipeline.targets_include(elements, track_elements): if targets and not self._pipeline.targets_include(elements, track_elements):
raise StreamError("Specified tracking targets that are not " raise StreamError("Specified tracking targets that are not "
"within the scope of primary targets") "within the scope of primary targets")
...@@ -900,6 +909,10 @@ class Stream(): ...@@ -900,6 +909,10 @@ class Stream():
for element in track_selected: for element in track_selected:
element._schedule_tracking() element._schedule_tracking()
if not targets:
self._pipeline.resolve_elements(track_selected)
return [], track_selected
# ArtifactCache.setup_remotes expects all projects to be fully loaded # ArtifactCache.setup_remotes expects all projects to be fully loaded
for project in self._context.get_projects(): for project in self._context.get_projects():
project.ensure_fully_loaded() project.ensure_fully_loaded()
......
...@@ -612,3 +612,25 @@ def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind): ...@@ -612,3 +612,25 @@ def test_track_include_junction(cli, tmpdir, datafiles, ref_storage, kind):
# Assert that we are now buildable because the source is # Assert that we are now buildable because the source is
# now cached. # now cached.
assert cli.get_element_state(project, element_name) == 'buildable' assert cli.get_element_state(project, element_name) == 'buildable'
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind):
project = os.path.join(datafiles.dirname, datafiles.basename)
element_path = os.path.join(project, 'elements')
subproject_path = os.path.join(project, 'files', 'sub-project')
sub_element_path = os.path.join(subproject_path, 'elements')
junction_path = os.path.join(element_path, 'junction.bst')
configure_project(project, {
'ref-storage': ref_storage,
'(@)': ['junction.bst:test.yml']
})
generate_junction(str(tmpdir.join('junction_repo')),
subproject_path, junction_path, store_ref=False)
result = cli.run(project=project, args=['track', 'junction.bst'])
result.assert_success()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment