summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-06 19:22:16 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-06 20:59:24 +0900
commit5ecd534cc795d596402ed0e14dde3a7a7ae1d789 (patch)
treece91b9b748eb45152ed994cc7e27a96f893c6db4
parent13c38e2d39958dc2ec34a241d867fa279c84fdae (diff)
downloadbuildstream-5ecd534cc795d596402ed0e14dde3a7a7ae1d789.tar.gz
tests/integration/workspace.py: Test that we don't crash when workspace artifacts are deleted
This is a regression test for #1017
-rw-r--r--tests/integration/workspace.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py
index 102d053fc..e30d54df3 100644
--- a/tests/integration/workspace.py
+++ b/tests/integration/workspace.py
@@ -255,3 +255,36 @@ def test_incremental_configure_commands_run_only_once(cli, tmpdir, 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.integration
+@pytest.mark.datafiles(DATA_DIR)
+def test_workspace_missing_last_successful(cli, datafiles, integration_cache):
+ project = str(datafiles)
+ workspace = os.path.join(cli.directory, 'workspace')
+ element_name = 'workspace/workspace-mount.bst'
+
+ # Open workspace
+ res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
+ 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
+ cache_dir = os.path.join(integration_cache, 'artifacts')
+ cli.remove_artifact_from_cache(project, element_name, cache_dir=cache_dir)
+
+ # 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