summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-01-22 07:57:47 +0100
committerJürg Billeter <j@bitron.ch>2019-01-24 14:38:50 +0100
commit3642c8e7b8106d4b8fba4f87d97f948c555a3d61 (patch)
tree29a07700b2d5c907ac85f0c713d05a67e5bfdb52
parent99b5c0af611f1eaa2eff710c3e9ee4ff5325d301 (diff)
downloadbuildstream-3642c8e7b8106d4b8fba4f87d97f948c555a3d61.tar.gz
tests/frontend/buildcheckout.py: Add default target test with junction
Test that `bst build` does not fail in a project where the list of default targets includes a junction (junctions cannot be built).
-rw-r--r--tests/frontend/buildcheckout.py47
-rw-r--r--tests/frontend/project_world/files/sub-project/elements/import-etc.bst4
-rw-r--r--tests/frontend/project_world/files/sub-project/files/etc-files/etc/animal.conf1
-rw-r--r--tests/frontend/project_world/files/sub-project/project.conf4
4 files changed, 56 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 156fab990..b35b14820 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -580,6 +580,53 @@ def test_build_checkout_junction(cli, tmpdir, datafiles):
assert contents == 'animal=Pony\n'
+# Test that default targets work with projects with junctions
+@pytest.mark.datafiles(DATA_DIR + "_world")
+def test_build_checkout_junction_default_targets(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ subproject_path = os.path.join(project, 'files', 'sub-project')
+ junction_path = os.path.join(project, 'elements', 'junction.bst')
+ element_path = os.path.join(project, 'elements', 'junction-dep.bst')
+ checkout = os.path.join(cli.directory, 'checkout')
+
+ # Create a repo to hold the subproject and generate a junction element for it
+ ref = generate_junction(tmpdir, subproject_path, junction_path)
+
+ # Create a stack element to depend on a cross junction element
+ #
+ element = {
+ 'kind': 'stack',
+ 'depends': [
+ {
+ 'junction': 'junction.bst',
+ 'filename': 'import-etc.bst'
+ }
+ ]
+ }
+ _yaml.dump(element, element_path)
+
+ # Now try to build it, this should automatically result in fetching
+ # the junction itself at load time.
+ result = cli.run(project=project, args=['build'])
+ result.assert_success()
+
+ # Assert that it's cached now
+ assert cli.get_element_state(project, 'junction-dep.bst') == 'cached'
+
+ # Now check it out
+ result = cli.run(project=project, args=[
+ 'artifact', 'checkout', 'junction-dep.bst', '--directory', checkout
+ ])
+ result.assert_success()
+
+ # Assert the content of /etc/animal.conf
+ filename = os.path.join(checkout, 'etc', 'animal.conf')
+ assert os.path.exists(filename)
+ with open(filename, 'r') as f:
+ contents = f.read()
+ assert contents == 'animal=Pony\n'
+
+
@pytest.mark.datafiles(DATA_DIR)
def test_build_checkout_workspaced_junction(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
diff --git a/tests/frontend/project_world/files/sub-project/elements/import-etc.bst b/tests/frontend/project_world/files/sub-project/elements/import-etc.bst
new file mode 100644
index 000000000..f0171990e
--- /dev/null
+++ b/tests/frontend/project_world/files/sub-project/elements/import-etc.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/etc-files
diff --git a/tests/frontend/project_world/files/sub-project/files/etc-files/etc/animal.conf b/tests/frontend/project_world/files/sub-project/files/etc-files/etc/animal.conf
new file mode 100644
index 000000000..db8c36cba
--- /dev/null
+++ b/tests/frontend/project_world/files/sub-project/files/etc-files/etc/animal.conf
@@ -0,0 +1 @@
+animal=Pony
diff --git a/tests/frontend/project_world/files/sub-project/project.conf b/tests/frontend/project_world/files/sub-project/project.conf
new file mode 100644
index 000000000..bbb8414a3
--- /dev/null
+++ b/tests/frontend/project_world/files/sub-project/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: subtest
+
+element-path: elements