diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-08-09 09:57:36 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-08-13 09:36:50 +0100 |
commit | 4b0b68cdff0326d2a9b3c59ad3df6f4c05218786 (patch) | |
tree | 2d1c90bb076d1a1e5a0f1dc8060f7c4378e663e3 /tests/integration | |
parent | 05d673ff2881e0f8a177622489ead9c9158d6032 (diff) | |
download | buildstream-4b0b68cdff0326d2a9b3c59ad3df6f4c05218786.tar.gz |
element.py: Don't reset a failed (but cached) workspaced Elementjennis/fix_failed_workspaces
A workspaced element can fail to build, if this happens, we
cache the result as a failure. This patch ensures that we
do not reset the cache data if a workspace has failed to build.
An integration test has also been added which ensures that we
are able to get the log of a failed workspace build.
Closes #1096
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/project/elements/autotools/amhello-failure.bst | 15 | ||||
-rw-r--r-- | tests/integration/workspace.py | 29 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/integration/project/elements/autotools/amhello-failure.bst b/tests/integration/project/elements/autotools/amhello-failure.bst new file mode 100644 index 000000000..771466b49 --- /dev/null +++ b/tests/integration/project/elements/autotools/amhello-failure.bst @@ -0,0 +1,15 @@ +kind: autotools +description: An element which is meant to fail + +config: + build-commands: + (>): + - this-will-fail + +depends: +- base.bst + +sources: +- kind: tar + url: project_dir:/files/amhello.tar.gz + ref: 9ba123fa4e660929e9a0aa99f0c487b7eee59c5e7594f3284d015640b90f5590 diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index 045f8c490..fe5e76ea3 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -7,6 +7,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX +from buildstream._exceptions import ErrorDomain pytestmark = pytest.mark.integration @@ -314,3 +315,31 @@ def test_workspace_missing_last_successful(cli, datafiles): # Build again, ensure we dont crash just because the artifact went missing res = cli.run(project=project, args=['build', element_name]) assert res.exit_code == 0 + + +# Check that we can still read failed workspace logs +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') +@pytest.mark.xfail(HAVE_SANDBOX == 'buildbox', reason='Not working with BuildBox', strict=True) +def test_workspace_failed_logs(cli, datafiles): + project = str(datafiles) + workspace = os.path.join(cli.directory, 'failing_amhello') + element_name = 'autotools/amhello-failure.bst' + + # Open workspace + res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name]) + res.assert_success() + + # Try to build and ensure the build fails + res = cli.run(project=project, args=['build', element_name]) + res.assert_main_error(ErrorDomain.STREAM, None) + assert cli.get_element_state(project, element_name) == 'failed' + + res = cli.run(project=project, args=['artifact', 'log', element_name]) + res.assert_success() + + log = res.output + # Assert that we can get the log + assert log != "" + fail_str = "FAILURE {}: Running build-commands".format(element_name) + assert fail_str in log |