From cb2d26c30f448c29cfd519e3d7809a3c7cd5aeac Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 6 May 2019 19:22:16 +0900 Subject: tests/integration/workspace.py: Test that we don't crash when workspace artifacts are deleted This is a regression test for #1017 --- tests/integration/workspace.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index 4ee0050d7..134ed6385 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -271,3 +271,36 @@ def test_incremental_configure_commands_run_only_once(cli, datafiles): res = cli.run(project=project, args=['build', element_name]) res.assert_success() assert not os.path.exists(os.path.join(workspace, 'prepared-again')) + + +# Test that rebuilding an already built workspaced element does +# not crash after the last successfully built artifact is removed +# from the cache +# +# A user can remove their artifact cache, or manually remove the +# artifact with `bst artifact delete`, or BuildStream can delete +# the last successfully built artifact for this workspace as a +# part of a cleanup job. +# +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') +def test_workspace_missing_last_successful(cli, datafiles): + project = str(datafiles) + workspace = os.path.join(cli.directory, 'workspace') + element_name = 'workspace/workspace-commanddir.bst' + + # Open workspace + res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name]) + assert res.exit_code == 0 + + # Build first, this will record the last successful build in local state + res = cli.run(project=project, args=['build', element_name]) + assert res.exit_code == 0 + + # Remove the artifact from the cache, invalidating the last successful build + res = cli.run(project=project, args=['artifact', 'delete', element_name]) + assert res.exit_code == 0 + + # 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 -- cgit v1.2.1