diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-03 16:10:25 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 04:14:24 -0400 |
commit | 4b0adf33098f5f180021e3d3b40be61463c2978d (patch) | |
tree | 7354a35aa105a5fdde54c8fbad80b0d6ccc8b4b2 /tests/frontend/buildcheckout.py | |
parent | cb5aa438a34fa4618373ffe8562e97f02b57410c (diff) | |
download | buildstream-4b0adf33098f5f180021e3d3b40be61463c2978d.tar.gz |
tests/frontend/buildcheckout.py: Added tests for `bst build` and `bst checkout`
Diffstat (limited to 'tests/frontend/buildcheckout.py')
-rw-r--r-- | tests/frontend/buildcheckout.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py new file mode 100644 index 000000000..e05b947b7 --- /dev/null +++ b/tests/frontend/buildcheckout.py @@ -0,0 +1,78 @@ +import os +import pytest +from tests.testutils.runcli import cli +from tests.testutils.repo import create_repo + +from buildstream import _yaml + +# Project directory +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project", +) + + +@pytest.mark.datafiles(DATA_DIR) +def test_build_checkout(datafiles, cli): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + # First build it + result = cli.run(project=project, args=['build', 'target.bst']) + assert result.exit_code == 0 + + # Now check it out + result = cli.run(project=project, args=[ + 'checkout', 'target.bst', checkout + ]) + assert result.exit_code == 0 + + # Check that the executable hello file is found in the checkout + filename = os.path.join(checkout, 'usr', 'bin', 'hello') + assert os.path.exists(filename) + + # Check that the executable hello file is found in the checkout + filename = os.path.join(checkout, 'usr', 'include', 'pony.h') + assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')]) +def test_fetch_build_checkout(cli, tmpdir, datafiles, kind): + checkout = os.path.join(cli.directory, 'checkout') + project = os.path.join(datafiles.dirname, datafiles.basename) + dev_files_path = os.path.join(project, 'files', 'dev-files') + element_path = os.path.join(project, 'elements') + element_name = 'build-test-{}.bst'.format(kind) + + # Create our repo object of the given source type with + # the dev files, and then collect the initial ref. + # + repo = create_repo(kind, str(tmpdir)) + ref = repo.create(dev_files_path) + + # Write out our test target + element = { + 'kind': 'import', + 'sources': [ + repo.source_config(ref=ref) + ] + } + _yaml.dump(element, + os.path.join(element_path, + element_name)) + + assert cli.get_element_state(project, element_name) == 'fetch needed' + result = cli.run(project=project, args=['build', element_name]) + assert result.exit_code == 0 + assert cli.get_element_state(project, element_name) == 'cached' + + # Now check it out + result = cli.run(project=project, args=[ + 'checkout', element_name, checkout + ]) + assert result.exit_code == 0 + + # Check that the pony.h include from files/dev-files exists + filename = os.path.join(checkout, 'usr', 'include', 'pony.h') + assert os.path.exists(filename) |