This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tpollard/artifacttemp
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 5f631c2fe15c5353b0aa6756bd4d6b18e9f9eb3a
Author: Tristan Van Berkom <[email protected]>
AuthorDate: Mon May 6 19:22:16 2019 +0900

    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(+)

diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py
index 4ee0050..134ed63 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.
+#
[email protected](DATA_DIR)
[email protected](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

Reply via email to