summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-05-06 19:22:16 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2019-05-06 11:10:12 +0000
commitcb2d26c30f448c29cfd519e3d7809a3c7cd5aeac (patch)
tree5985d0aa2387fd29be19f72409200ebaaebfea61 /tests
parentd031349a5f82882bff1067b11bdc40d13bb6fe46 (diff)
downloadbuildstream-cb2d26c30f448c29cfd519e3d7809a3c7cd5aeac.tar.gz
tests/integration/workspace.py: Test that we don't crash when workspace artifacts are deletedtristan/fix-missing-workspace-artifact
This is a regression test for #1017
Diffstat (limited to 'tests')
-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 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