You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:46:03 UTC

[buildstream] branch tristan/fix-workspace-build-all-1.2 created (now 0b35e3e)

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

root pushed a change to branch tristan/fix-workspace-build-all-1.2
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 0b35e3e  tests/frontend/workspace.py: Test that all elements build with workspace in play

This branch includes the following new commits:

     new 077b29e  element.py: Force resolve intermediate dependency cache keys
     new 0b35e3e  tests/frontend/workspace.py: Test that all elements build with workspace in play

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/02: element.py: Force resolve intermediate dependency cache keys

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch tristan/fix-workspace-build-all-1.2
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 077b29ea43ee7c1f02afd511c62ed7a95b3b4db6
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Sun Feb 24 18:45:08 2019 +0900

    element.py: Force resolve intermediate dependency cache keys
    
    When a cache key is discovered (e.g.: due to a workspace build completing),
    then we have no guarantee that reverse dependency cache keys will be
    updated in order.
    
    As such, we must ensure that `Element._update_state()` serializes this
    and ensures that cache keys for intermediate dependencies get resolved.
    
    This fixes #919
---
 buildstream/element.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/buildstream/element.py b/buildstream/element.py
index bc939bc..92c9d01 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1092,6 +1092,18 @@ class Element(Plugin):
                     return
 
         if self.__strict_cache_key is None:
+
+            # We cannot make the assumption that dependency cache keys
+            # have already been resolved if possible.
+            #
+            # If a cache key was recently discovered, we need to be sure
+            # that the interemediate dependencies get their cache keys
+            # resolved before calculating this element's cache key.
+            #
+            for e in self.dependencies(Scope.BUILD):
+                if e.__strict_cache_key is None:
+                    e._update_state()
+
             dependencies = [
                 e.__strict_cache_key for e in self.dependencies(Scope.BUILD)
             ]


[buildstream] 02/02: tests/frontend/workspace.py: Test that all elements build with workspace in play

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch tristan/fix-workspace-build-all-1.2
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 0b35e3e701b6694b4dada4283cf4923267236070
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Feb 23 17:35:58 2019 +0900

    tests/frontend/workspace.py: Test that all elements build with workspace in play
    
    Tests that the target is still built even when a workspace is open
    on a runtime dependency of a build-only dependency.
    
    This adds the regression test provided by Matthew Yates for issue #919
---
 tests/frontend/workspace.py                        | 42 ++++++++++++++++++++++
 .../workspaced-build-dep/elements/elem1.bst        |  5 +++
 .../workspaced-build-dep/elements/elem2.bst        |  5 +++
 .../workspaced-build-dep/elements/elem3.bst        |  9 +++++
 .../workspaced-build-dep/elements/stack.bst        |  5 +++
 tests/frontend/workspaced-build-dep/files/file1    |  0
 tests/frontend/workspaced-build-dep/files/file2    |  0
 tests/frontend/workspaced-build-dep/files/file3    |  0
 tests/frontend/workspaced-build-dep/project.conf   |  8 +++++
 9 files changed, 74 insertions(+)

diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 8799362..163bda5 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -782,3 +782,45 @@ def test_cache_key_workspace_in_dependencies(cli, tmpdir, datafiles, strict):
 
     # Check that the original /usr/bin/hello is not in the checkout
     assert not os.path.exists(os.path.join(checkout, 'usr', 'bin', 'hello'))
+
+
+# This strange test tests against a regression raised in issue #919,
+# where opening a workspace on a runtime dependency of a build only
+# dependency causes `bst build` to not build the specified target
+# but just successfully builds the workspaced element and happily
+# exits without completing the build.
+#
+BUILD_ALL_DIR = os.path.join(
+    os.path.dirname(os.path.realpath(__file__)),
+    "workspaced-build-dep",
+)
+
+
+@pytest.mark.datafiles(BUILD_ALL_DIR)
+@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
+def test_build_all(cli, tmpdir, datafiles, strict):
+    project = str(datafiles)
+    workspace = os.path.join(str(tmpdir), 'workspace')
+
+    # Configure strict mode
+    strict_mode = True
+    if strict != 'strict':
+        strict_mode = False
+    cli.configure({
+        'projects': {
+            'test': {
+                'strict': strict_mode
+            }
+        }
+    })
+
+    # First open the workspace
+    result = cli.run(project=project, args=['workspace', 'open', 'elem1.bst', workspace])
+    result.assert_success()
+
+    # Now build the target elem3.bst
+    result = cli.run(project=project, args=['build', 'elem3.bst'])
+    result.assert_success()
+
+    # Assert that the target is built
+    assert cli.get_element_state(project, 'elem3.bst') == 'cached'
diff --git a/tests/frontend/workspaced-build-dep/elements/elem1.bst b/tests/frontend/workspaced-build-dep/elements/elem1.bst
new file mode 100644
index 0000000..eed39a9
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem1.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+  path: files/file1
diff --git a/tests/frontend/workspaced-build-dep/elements/elem2.bst b/tests/frontend/workspaced-build-dep/elements/elem2.bst
new file mode 100644
index 0000000..1233c08
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem2.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+  path: files/file2
diff --git a/tests/frontend/workspaced-build-dep/elements/elem3.bst b/tests/frontend/workspaced-build-dep/elements/elem3.bst
new file mode 100644
index 0000000..4c9bf89
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem3.bst
@@ -0,0 +1,9 @@
+kind: import
+
+depends:
+- filename: stack.bst
+  type: build
+
+sources:
+- kind: local
+  path: files/file3
diff --git a/tests/frontend/workspaced-build-dep/elements/stack.bst b/tests/frontend/workspaced-build-dep/elements/stack.bst
new file mode 100644
index 0000000..6ba3614
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/stack.bst
@@ -0,0 +1,5 @@
+kind: stack
+
+depends:
+- elem1.bst
+- elem2.bst
diff --git a/tests/frontend/workspaced-build-dep/files/file1 b/tests/frontend/workspaced-build-dep/files/file1
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/workspaced-build-dep/files/file2 b/tests/frontend/workspaced-build-dep/files/file2
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/workspaced-build-dep/files/file3 b/tests/frontend/workspaced-build-dep/files/file3
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/workspaced-build-dep/project.conf b/tests/frontend/workspaced-build-dep/project.conf
new file mode 100644
index 0000000..e017957
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/project.conf
@@ -0,0 +1,8 @@
+# Unique project name
+name: test
+
+# Required BuildStream format version
+format-version: 12
+
+# Subdirectory where elements are stored
+element-path: elements