summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-19 19:24:18 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-20 18:29:14 +0900
commitda95c63924285d3234e9642435de5b5cef0ea5e0 (patch)
tree339916d1b95a28554b6ecfc5f5d073d6a3a05c49
parent2bcae91f1e26d8396023425dce34b55a7e4095e5 (diff)
downloadbuildstream-da95c63924285d3234e9642435de5b5cef0ea5e0.tar.gz
tests/frontend/track.py: Testing behavior of cross junction tracking
o Test that this fails gracefully when the toplevel project uses inline ref-storage o Test that we successfully track cross junctioned elements when the project uses project.refs
-rw-r--r--tests/frontend/track-cross-junction/files/usr/include/pony.h12
-rw-r--r--tests/frontend/track-cross-junction/subproject-junction.bst4
-rw-r--r--tests/frontend/track-cross-junction/subproject.bst5
-rw-r--r--tests/frontend/track-cross-junction/subproject/project.conf1
-rw-r--r--tests/frontend/track.py74
5 files changed, 96 insertions, 0 deletions
diff --git a/tests/frontend/track-cross-junction/files/usr/include/pony.h b/tests/frontend/track-cross-junction/files/usr/include/pony.h
new file mode 100644
index 000000000..40bd0c2e7
--- /dev/null
+++ b/tests/frontend/track-cross-junction/files/usr/include/pony.h
@@ -0,0 +1,12 @@
+#ifndef __PONY_H__
+#define __PONY_H__
+
+#define PONY_BEGIN "Once upon a time, there was a pony."
+#define PONY_END "And they lived happily ever after, the end."
+
+#define MAKE_PONY(story) \
+ PONY_BEGIN \
+ story \
+ PONY_END
+
+#endif /* __PONY_H__ */
diff --git a/tests/frontend/track-cross-junction/subproject-junction.bst b/tests/frontend/track-cross-junction/subproject-junction.bst
new file mode 100644
index 000000000..c88189cb0
--- /dev/null
+++ b/tests/frontend/track-cross-junction/subproject-junction.bst
@@ -0,0 +1,4 @@
+kind: junction
+sources:
+- kind: local
+ path: subproject
diff --git a/tests/frontend/track-cross-junction/subproject.bst b/tests/frontend/track-cross-junction/subproject.bst
new file mode 100644
index 000000000..0a9e5ab1e
--- /dev/null
+++ b/tests/frontend/track-cross-junction/subproject.bst
@@ -0,0 +1,5 @@
+kind: stack
+
+depends:
+- filename: subtarget.bst
+ junction: subproject-junction.bst
diff --git a/tests/frontend/track-cross-junction/subproject/project.conf b/tests/frontend/track-cross-junction/subproject/project.conf
new file mode 100644
index 000000000..b32753625
--- /dev/null
+++ b/tests/frontend/track-cross-junction/subproject/project.conf
@@ -0,0 +1 @@
+name: test
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index d007a8b77..80959a5a9 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -2,6 +2,7 @@ import os
import pytest
from tests.testutils import cli, create_repo, ALL_REPO_KINDS
+from buildstream._exceptions import ErrorDomain
from buildstream import _yaml
# Project directory
@@ -215,3 +216,76 @@ def test_track_optional(cli, tmpdir, datafiles, ref_storage):
# Assert that the keys are different when having
# tracked separate branches
assert test_key != master_key
+
+
+@pytest.mark.datafiles(os.path.join(TOP_DIR, 'track-cross-junction'))
+@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
+def test_track_cross_junction(cli, tmpdir, datafiles, ref_storage):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ dev_files_path = os.path.join(project, 'files')
+ target_path = os.path.join(project, 'target.bst')
+ subtarget_path = os.path.join(project, 'subproject', 'subtarget.bst')
+
+ # Create our repo object of the given source type with
+ # the dev files, and then collect the initial ref.
+ #
+ repo = create_repo('git', str(tmpdir))
+ ref = repo.create(dev_files_path)
+
+ # Generate two elements using the git source, one in
+ # the main project and one in the subproject.
+ generate_element(repo, target_path, dep_name='subproject.bst')
+ generate_element(repo, subtarget_path)
+
+ # Generate project.conf
+ #
+ project_conf = {
+ 'name': 'test',
+ 'ref-storage': ref_storage
+ }
+ _yaml.dump(project_conf, os.path.join(project, 'project.conf'))
+
+ #
+ # FIXME: This can be simplified when we have support
+ # for addressing of junctioned elements.
+ #
+ def get_subproject_element_state():
+ result = cli.run(project=project, args=[
+ 'show', '--deps', 'all',
+ '--format', '%{name}|%{state}', 'target.bst'
+ ])
+ result.assert_success()
+
+ # Create two dimentional list of the result,
+ # first line should be the junctioned element
+ lines = [
+ line.split('|')
+ for line in result.output.splitlines()
+ ]
+ assert lines[0][0] == 'subproject-junction.bst:subtarget.bst'
+ return lines[0][1]
+
+ #
+ # Assert that we have no reference yet for the cross junction element
+ #
+ assert get_subproject_element_state() == 'no reference'
+
+ # Track recursively across the junction
+ result = cli.run(project=project, args=['track', '--deps', 'all', 'target.bst'])
+
+ if ref_storage == 'inline':
+ #
+ # Cross junction tracking is not allowed when the toplevel project
+ # is using inline ref storage.
+ #
+ result.assert_main_error(ErrorDomain.PIPELINE, 'untrackable-sources')
+ else:
+ #
+ # Tracking is allowed with project.refs ref storage
+ #
+ result.assert_success()
+
+ #
+ # Assert that we now have a ref for the subproject element
+ #
+ assert get_subproject_element_state() == 'buildable'