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

[buildstream] branch tristan/stop-stripping-whitespace created (now fbe2c64)

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

not-in-ldap pushed a change to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at fbe2c64  tests/cachekey: Updated cache key test now that we don't strip whitespace

This branch includes the following new commits:

     new c506046  _yaml.py: Stop stripping whitespace from loaded YAML
     new de7d438  plugin.py: Removed documentation notes about whitespace stripping
     new a9504ee  tests/format/project.py: Added regression test for the preservation of whitespace
     new 2d2a7a3  NEWS: Document minor breaking change due to not automatically stripping whitespace
     new 73cfbe5  buildelement.py: Strip the commands fed to the shell
     new fbe2c64  tests/cachekey: Updated cache key test now that we don't strip whitespace

The 6 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] 04/06: NEWS: Document minor breaking change due to not automatically stripping whitespace

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 2d2a7a3a1e65e480976582eb7a87d51a661df103
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 18:40:17 2018 +0900

    NEWS: Document minor breaking change due to not automatically stripping whitespace
---
 NEWS | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/NEWS b/NEWS
index b8003ce..7ee836c 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,14 @@
 buildstream 1.3.1
 =================
 
+  o BREAKING CHANGE: BuildStream no longer strips whitespace from loaded YAML
+    by default.
+
+    This is a very minor breakage, because unless the user has explicitly
+    quoted a string with intentional whitespace, the YAML library will automatically
+    strip whitespace in compliance with the specification. This change results
+    in explicit whitespace being allowed to be specified in YAML.
+
   o BREAKING CHANGE: Default strip-commands have been removed as they are too
     specific. Recommendation if you are building in Linux is to use the
     ones being used in freedesktop-sdk project, for example


[buildstream] 01/06: _yaml.py: Stop stripping whitespace from loaded YAML

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c5060461949444e81c37437010878beda973bcb8
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 18:36:59 2018 +0900

    _yaml.py: Stop stripping whitespace from loaded YAML
    
    Whitespace is already stripped from strings by the YAML library unless
    it is explicitly quoted to have leading and trailing whitespace.
    
    This fixes issue #403
---
 buildstream/_yaml.py | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index 8d7302b..125d0e1 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -360,9 +360,6 @@ _sentinel = object()
 # Raises:
 #    LoadError, when the value found is not of the expected type
 #
-# Note:
-#    Returned strings are stripped of leading and trailing whitespace
-#
 def node_get(node, expected_type, key, indices=None, *, default_value=_sentinel, allow_none=False):
     value = node.get(key, default_value)
     provenance = node_get_provenance(node)
@@ -407,10 +404,6 @@ def node_get(node, expected_type, key, indices=None, *, default_value=_sentinel,
                             "{}: Value of '{}' is not of the expected type '{}'"
                             .format(provenance, path, expected_type.__name__))
 
-    # Trim it at the bud, let all loaded strings from yaml be stripped of whitespace
-    if isinstance(value, str):
-        value = value.strip()
-
     return value
 
 


[buildstream] 05/06: buildelement.py: Strip the commands fed to the shell

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 73cfbe52f2ba82e83383dc5d81de5042516ae5ac
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 20:55:58 2018 +0900

    buildelement.py: Strip the commands fed to the shell
    
    Otherwise the formatting of variables can result in multiple
    newlines fed to the shell command, which breaks builds.
---
 buildstream/buildelement.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py
index 06c6235..5eb4391 100644
--- a/buildstream/buildelement.py
+++ b/buildstream/buildelement.py
@@ -293,6 +293,13 @@ class BuildElement(Element):
         return commands
 
     def __run_command(self, sandbox, cmd, cmd_name):
+
+        # Because of variable expansion, sometimes the command
+        # may have trailing whitespace or newlines, strip this
+        # out and ensure we feed a sanitized string to the shell.
+        #
+        cmd = cmd.strip()
+
         # Note the -e switch to 'sh' means to exit with an error
         # if any untested command fails.
         #


[buildstream] 06/06: tests/cachekey: Updated cache key test now that we don't strip whitespace

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit fbe2c645ec649d15f71932c945cba5a2fe9a0352
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 20:56:56 2018 +0900

    tests/cachekey: Updated cache key test now that we don't strip whitespace
---
 tests/cachekey/project/elements/build1.expected | 2 +-
 tests/cachekey/project/elements/build2.expected | 2 +-
 tests/cachekey/project/sources/pip1.expected    | 2 +-
 tests/cachekey/project/target.expected          | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/cachekey/project/elements/build1.expected b/tests/cachekey/project/elements/build1.expected
index 623a491..2b82d60 100644
--- a/tests/cachekey/project/elements/build1.expected
+++ b/tests/cachekey/project/elements/build1.expected
@@ -1 +1 @@
-dadb8f86874f714b4f6d4c9025332934efb7e85c38f6a68b1267746ae8f43f24
+c5f3e9cfa9f884582a693dfb8b0bf7cb667c3d56e4ce628ce68ccea181a7616a
\ No newline at end of file
diff --git a/tests/cachekey/project/elements/build2.expected b/tests/cachekey/project/elements/build2.expected
index 34853b9..b0a6d16 100644
--- a/tests/cachekey/project/elements/build2.expected
+++ b/tests/cachekey/project/elements/build2.expected
@@ -1 +1 @@
-f81cefce283dd3581ba2fc865ff9c2763119274b114b12edb4e87196cfff8b2a
+53f7822567b3a2c62849e806dba31cc7e5a9ac4e30243927b7fb49c12ee48848
\ No newline at end of file
diff --git a/tests/cachekey/project/sources/pip1.expected b/tests/cachekey/project/sources/pip1.expected
index a857140..6a3895d 100644
--- a/tests/cachekey/project/sources/pip1.expected
+++ b/tests/cachekey/project/sources/pip1.expected
@@ -1 +1 @@
-09d873158f35ea64e67919373a6cfbd4aaba9321b817c89317b1350da8267318
\ No newline at end of file
+2e88fa60ed789a4eeb554db33fdd1a7c77cc767df223d3cc339154abf774a740
\ No newline at end of file
diff --git a/tests/cachekey/project/target.expected b/tests/cachekey/project/target.expected
index 66a3803..3a4be0e 100644
--- a/tests/cachekey/project/target.expected
+++ b/tests/cachekey/project/target.expected
@@ -1 +1 @@
-92dae6a712b4f91f4fdbdf8dad732cf07ff4da092a319fa4f4b261a9287640de
+b73203c1ee5c19e3ef35dd56900856b09603adb68877da861bbe0a29bf4b2ee0
\ No newline at end of file


[buildstream] 02/06: plugin.py: Removed documentation notes about whitespace stripping

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit de7d43845d8034a4fde5f36ce98032612c204f00
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 18:38:00 2018 +0900

    plugin.py: Removed documentation notes about whitespace stripping
    
    The public methods for loading YAML no longer strip whitespace.
---
 buildstream/plugin.py | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index 2f51c88..1fc96a9 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -340,9 +340,6 @@ class Plugin():
         Raises:
            :class:`.LoadError`: When *member_name* is not found and no *default* was provided
 
-        Note:
-           Returned strings are stripped of leading and trailing whitespace
-
         **Example:**
 
         .. code:: python
@@ -441,9 +438,6 @@ class Plugin():
         Raises:
            :class:`.LoadError`
 
-        Note:
-           Returned strings are stripped of leading and trailing whitespace
-
         **Example:**
 
         .. code:: python


[buildstream] 03/06: tests/format/project.py: Added regression test for the preservation of whitespace

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

not-in-ldap pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit a9504ee16416da1d0972bb9d5531a4b4f78a9d63
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 18:39:20 2018 +0900

    tests/format/project.py: Added regression test for the preservation of whitespace
    
    Test that explicitly quoted strings loaded from YAML have their
    leading and trailing whitespace preserved.
---
 tests/format/project.py                               | 12 ++++++++++++
 tests/format/project/preserve-whitespace/manual.bst   |  6 ++++++
 tests/format/project/preserve-whitespace/project.conf |  1 +
 3 files changed, 19 insertions(+)

diff --git a/tests/format/project.py b/tests/format/project.py
index 02e8afb..6096a02 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -207,3 +207,15 @@ def test_empty_depends(cli, datafiles):
     project = os.path.join(datafiles.dirname, datafiles.basename, "empty-depends")
     result = cli.run(project=project, args=['show', 'manual.bst'])
     result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+def test_preserve_whitespace(cli, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename, "preserve-whitespace")
+    result = cli.run(project=project, args=['show', '--format', '%{vars}', 'manual.bst'])
+    result.assert_success()
+
+    loaded = _yaml.load_data(result.output)
+    assert loaded['trail'] == 'trailing whitespace '
+    assert loaded['lead'] == ' leading whitespace'
+    assert loaded['both'] == ' both '
diff --git a/tests/format/project/preserve-whitespace/manual.bst b/tests/format/project/preserve-whitespace/manual.bst
new file mode 100644
index 0000000..ece4356
--- /dev/null
+++ b/tests/format/project/preserve-whitespace/manual.bst
@@ -0,0 +1,6 @@
+kind: manual
+
+variables:
+  trail: "trailing whitespace "
+  lead: " leading whitespace"
+  both: " both "
diff --git a/tests/format/project/preserve-whitespace/project.conf b/tests/format/project/preserve-whitespace/project.conf
new file mode 100644
index 0000000..b327536
--- /dev/null
+++ b/tests/format/project/preserve-whitespace/project.conf
@@ -0,0 +1 @@
+name: test