diff options
author | James Ennis <james.ennis@codethink.com> | 2019-01-09 16:19:08 +0000 |
---|---|---|
committer | James Ennis <james.ennis@codethink.com> | 2019-01-10 14:07:25 +0000 |
commit | 431b77963dbc272570fb05760c0b0bf3b8d29279 (patch) | |
tree | 5cc75f7da18c901fc71d0c96e3d7fe6f4089e63c | |
parent | c7c38be174af9225b73fa6f43485b59f146a7149 (diff) | |
download | buildstream-431b77963dbc272570fb05760c0b0bf3b8d29279.tar.gz |
tests/frontend/buildcheckout.py: Add new tests for checking out artifacts
bst artifact subcommands are able to handle artifact refs as well as
element names. These tests ensure that we can checkout an artifact
or multiple artifacts by using their refs.
-rw-r--r-- | tests/frontend/buildcheckout.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 8c7e22a85..52c391df1 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -631,3 +631,67 @@ def test_build_checkout_cross_junction(datafiles, cli, tmpdir): filename = os.path.join(checkout, 'etc', 'animal.conf') assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) +def test_checkout_single_artifact(datafiles, cli, tmpdir): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + result = cli.run(project=project, args=['build', 'import-bin.bst']) + result.assert_success() + + key = cli.get_element_key(project, 'import-bin.bst') + artifact = os.path.join('test', 'import-bin', key) # 'test' is the project's name + + result = cli.run(project=project, args=['artifact', 'checkout', artifact, '--directory', checkout]) + result.assert_success() + + filename = os.path.join(checkout, 'usr', 'bin', 'hello') + assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) +def test_checkout_multiple_artifacts(datafiles, cli, tmpdir): + # Now let's built and checkout two of the built artifacts + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + result = cli.run(project=project, args=['build', 'target.bst']) # depends on import-bin and import-dev.bst + result.assert_success() + + bin_key = cli.get_element_key(project, 'import-bin.bst') + artifact1 = os.path.join('test', 'import-bin', bin_key) # 'test' is the project's name + dev_key = cli.get_element_key(project, 'import-dev.bst') + artifact2 = os.path.join('test', 'import-dev', dev_key) + + result = cli.run(project=project, args=['artifact', 'checkout', artifact1, artifact2, + '--directory', checkout]) + result.assert_success() + + bin_file = os.path.join(checkout, 'usr', 'bin', 'hello') + assert os.path.exists(bin_file) + dev_file = os.path.join(checkout, 'usr', 'include', 'pony.h') + assert os.path.exists(dev_file) + + +@pytest.mark.datafiles(DATA_DIR) +def test_checkout_element_and_artifact(datafiles, cli, tmpdir): + # Now let's built and checkout two of the built artifacts + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + result = cli.run(project=project, args=['build', 'target.bst']) # depends on import-bin and import-dev.bst + result.assert_success() + + dev_key = cli.get_element_key(project, 'import-dev.bst') + artifact = os.path.join('test', 'import-dev', dev_key) + + result = cli.run(project=project, args=['artifact', 'checkout', 'import-bin.bst', artifact, + '--directory', checkout]) + result.assert_success() + + bin_file = os.path.join(checkout, 'usr', 'bin', 'hello') + assert os.path.exists(bin_file) + dev_file = os.path.join(checkout, 'usr', 'include', 'pony.h') + assert os.path.exists(dev_file) |