summaryrefslogtreecommitdiff
path: root/tests/frontend/buildcheckout.py
diff options
context:
space:
mode:
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)