diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-05-19 09:27:46 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-05-19 09:27:46 +0000 |
commit | 7cdd7f4e085d6750235c2f8e8f578eae07db9655 (patch) | |
tree | 11b68228831bfb029a4bbd5deba315415f9abb30 | |
parent | ef00fc2f384631a001442b5cd2b5765c58809720 (diff) | |
parent | a8b322246b54a5061fac9d47e743534b1c15fc08 (diff) | |
download | buildstream-7cdd7f4e085d6750235c2f8e8f578eae07db9655.tar.gz |
Merge branch 'bschubert/ensure-composite-works-with-variables' into 'master'
node.pyx: Deep clone ScalarNode too
See merge request BuildStream/buildstream!1929
-rw-r--r-- | src/buildstream/node.pyx | 6 | ||||
-rw-r--r-- | tests/format/variables.py | 21 | ||||
-rw-r--r-- | tests/format/variables/shared_variables/one.bst | 6 | ||||
-rw-r--r-- | tests/format/variables/shared_variables/project.conf | 2 | ||||
-rw-r--r-- | tests/format/variables/shared_variables/shared.yml | 3 | ||||
-rw-r--r-- | tests/format/variables/shared_variables/two.bst | 6 |
6 files changed, 42 insertions, 2 deletions
diff --git a/src/buildstream/node.pyx b/src/buildstream/node.pyx index ea61d9366..32b8c130c 100644 --- a/src/buildstream/node.pyx +++ b/src/buildstream/node.pyx @@ -106,7 +106,7 @@ cdef class Node: raise NotImplementedError() cpdef object strip_node_info(self): - """ Remove all the node information (provenance) and return the underlying data as plain python objects + """ Remove all the node information (provenance) and return the underlying data as plain python objects Returns: (list, dict, str, None): the underlying data that was held in the node structure. @@ -420,7 +420,9 @@ cdef class ScalarNode(Node): ############################################################# cpdef ScalarNode clone(self): - return self + return ScalarNode.__new__( + ScalarNode, self.file_index, self.line, self.column, self.value + ) cpdef object strip_node_info(self): return self.value diff --git a/tests/format/variables.py b/tests/format/variables.py index 81bda291b..5f07067f3 100644 --- a/tests/format/variables.py +++ b/tests/format/variables.py @@ -117,3 +117,24 @@ def test_use_of_protected_var_in_element(cli, datafiles, protected_var): result = cli.run(project=project, args=["build", "target.bst"]) result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROTECTED_VARIABLE_REDEFINED) + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, "shared_variables")) +def test_variables_are_resolved_in_elements_context(cli, datafiles): + project = str(datafiles) + + result = cli.run(project=project, args=["build"]) + result.assert_success() + + checkout_dir = os.path.join(project, "checkout") + for elem in ["one", "two"]: + result = cli.run( + project=project, + args=["artifact", "checkout", "--directory", os.path.join(checkout_dir, elem), "{}.bst".format(elem)], + ) + result.assert_success() + + assert (os.listdir(os.path.join(checkout_dir, "one")), os.listdir(os.path.join(checkout_dir, "two"))) == ( + ["one.bst"], + ["two.bst"], + ) diff --git a/tests/format/variables/shared_variables/one.bst b/tests/format/variables/shared_variables/one.bst new file mode 100644 index 000000000..0f19e91b1 --- /dev/null +++ b/tests/format/variables/shared_variables/one.bst @@ -0,0 +1,6 @@ +kind: import + +(@): shared.yml + +variables: + import-path: one.bst diff --git a/tests/format/variables/shared_variables/project.conf b/tests/format/variables/shared_variables/project.conf new file mode 100644 index 000000000..ee1dfb2c7 --- /dev/null +++ b/tests/format/variables/shared_variables/project.conf @@ -0,0 +1,2 @@ +name: shared-vars +min-version: 2.0 diff --git a/tests/format/variables/shared_variables/shared.yml b/tests/format/variables/shared_variables/shared.yml new file mode 100644 index 000000000..8266757cd --- /dev/null +++ b/tests/format/variables/shared_variables/shared.yml @@ -0,0 +1,3 @@ +sources: + - kind: local + path: "%{import-path}" diff --git a/tests/format/variables/shared_variables/two.bst b/tests/format/variables/shared_variables/two.bst new file mode 100644 index 000000000..ad621d760 --- /dev/null +++ b/tests/format/variables/shared_variables/two.bst @@ -0,0 +1,6 @@ +kind: import + +(@): shared.yml + +variables: + import-path: two.bst |