summaryrefslogtreecommitdiff
path: root/tests/frontend/buildcheckout.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-01-24 15:10:08 +0000
committerJürg Billeter <j@bitron.ch>2019-01-24 15:10:08 +0000
commit05587f22bd157e188e2083f11893e7c801b3f50e (patch)
tree416f3215a19c06a52a890427815c842c6eca3797 /tests/frontend/buildcheckout.py
parent24bd8994180fbf1b4bc00754d62ccc31ed6136ee (diff)
parent50c5159f1cf760a75abd15cf655ec82351b378ac (diff)
downloadbuildstream-05587f22bd157e188e2083f11893e7c801b3f50e.tar.gz
Merge branch 'issue-638-validate-all-files' into 'master'
Add support for default targets See merge request BuildStream/buildstream!925
Diffstat (limited to 'tests/frontend/buildcheckout.py')
-rw-r--r--tests/frontend/buildcheckout.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 8c7e22a85..b35b14820 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -2,6 +2,7 @@ import os
import tarfile
import hashlib
import pytest
+import subprocess
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
from tests.testutils.site import IS_WINDOWS
@@ -61,6 +62,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
assert os.path.exists(filename)
+@pytest.mark.datafiles(DATA_DIR + "_world")
+def test_build_default_all(datafiles, cli):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
+ output_dir = os.path.join(cli.directory, "logs", "test")
+
+ expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
+ expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
+
+ results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
+ results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
+
+ assert results == expected
+
+
+@pytest.mark.datafiles(DATA_DIR + "_default")
+def test_build_default(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ results = cli.get_element_state(project, "target2.bst")
+ expected = "cached"
+ assert results == expected
+
+
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("strict,hardlinks", [
("non-strict", "hardlinks"),
@@ -550,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)