diff options
author | Jürg Billeter <j@bitron.ch> | 2019-01-22 07:57:47 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-01-22 08:08:18 +0100 |
commit | 032d6513a76be9d09e47f5172724a6d82682960c (patch) | |
tree | b96a43979930e4a4cd8e54660dba41d88751542d | |
parent | f291fd9c2f898be7c3f4cfc4c46d370239549647 (diff) | |
download | buildstream-032d6513a76be9d09e47f5172724a6d82682960c.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).
4 files changed, 56 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index f985d1e94..fcd4fe911 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -579,6 +579,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=[ + 'checkout', 'junction-dep.bst', 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 |