summaryrefslogtreecommitdiff
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:29:15 +0900
commit627502a63ab1e1cf1e878d33b9983df88f01e03f (patch)
tree02151da8ccc92b7011b999872ae97baf46d7f4df
parent93083ac889872cbb36b2ff33af5ef1df71cf52aa (diff)
downloadbuildstream-tristan/fix-build-track-all-no-strict-1.2.tar.gz
tests/frontend/buildtrack.py: Test that tracking builds in non-strict mode actually buildtristan/fix-build-track-all-no-strict-1.2
This is a regression test for issue #1014
-rw-r--r--tests/frontend/buildtrack.py78
1 files changed, 77 insertions, 1 deletions
diff --git a/tests/frontend/buildtrack.py b/tests/frontend/buildtrack.py
index cd726cd71..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
@@ -150,6 +150,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=['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