summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-08 19:08:45 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-09 17:20:03 +0900
commit223834422d12136879ea2840bd8c8270da87b657 (patch)
treef66f384eb076af98a56fcbb37a5ea2bd1b778b00 /tests
parent854ba3a141f0351520640bb4ac79a0a2a7260ef4 (diff)
downloadbuildstream-223834422d12136879ea2840bd8c8270da87b657.tar.gz
tests/frontend/buildtrack.py: Test that tracking builds in non-strict mode actually buildtristan/fix-build-track-all-no-strict
This is a regression test for issue #1014
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/buildtrack.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/frontend/buildtrack.py b/tests/frontend/buildtrack.py
index d12481c6a..d42b6d1ba 100644
--- a/tests/frontend/buildtrack.py
+++ b/tests/frontend/buildtrack.py
@@ -12,6 +12,7 @@ from buildstream import _yaml
from buildstream.testing import create_repo
from buildstream.testing import cli # pylint: disable=unused-import
from buildstream._exceptions import ErrorDomain
+from tests.testutils import generate_junction
from . import configure_project
@@ -156,6 +157,82 @@ def test_build_track(cli, datafiles, tmpdir, ref_storage, strict,
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=['source', '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