summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2020-08-13 22:00:31 +0000
committerChandan Singh <chandan@chandansingh.net>2020-08-18 20:00:56 +0000
commitcccfe96f3747ec0b72c220c9c0af2517cce7b701 (patch)
treee0d4b561598e987ad709363bd28a56a02c62ae25
parent4d2735ce50b3cd3d6736ef93736315c292ad3c56 (diff)
downloadbuildstream-cccfe96f3747ec0b72c220c9c0af2517cce7b701.tar.gz
Bump minimum version requirement for ruamel.yamlchandan/upgrade-ruamel
ruamel.yaml <= 0.16.6 suffers from a bug where ruamel's yaml dumper crashes when used on a sequence that has comments before it. In BuildStream, this manifests in form of issues like #1265. See upstream issue at https://sourceforge.net/p/ruamel-yaml/tickets/335. Also, add a regression test for it. Fixes #1265.
-rw-r--r--requirements/requirements.in2
-rw-r--r--tests/frontend/source-track/comments.bst13
-rw-r--r--tests/frontend/track.py23
3 files changed, 37 insertions, 1 deletions
diff --git a/requirements/requirements.in b/requirements/requirements.in
index ca38d710e..f62623fb0 100644
--- a/requirements/requirements.in
+++ b/requirements/requirements.in
@@ -4,7 +4,7 @@ Jinja2 >= 2.10
pluginbase
protobuf >= 3.6
psutil
-ruamel.yaml >= 0.16
+ruamel.yaml >= 0.16.7
ruamel.yaml.clib >= 0.1.2
setuptools
pyroaring
diff --git a/tests/frontend/source-track/comments.bst b/tests/frontend/source-track/comments.bst
new file mode 100644
index 000000000..887c37b98
--- /dev/null
+++ b/tests/frontend/source-track/comments.bst
@@ -0,0 +1,13 @@
+kind: manual
+
+config:
+ build-commands:
+ (<):
+ # This is a multi-line comment.
+ # It should have no effect and should be ignored safely.
+ - |
+ true
+
+sources:
+- kind: remote
+ url: project-root:/files/apples
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index ba569d210..51768f04e 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -396,3 +396,26 @@ def test_no_needless_overwrite(cli, tmpdir, datafiles):
track2_mtime = os.path.getmtime(path_to_target)
assert track1_mtime == track2_mtime
+
+
+# Regression test for https://gitlab.com/BuildStream/buildstream/-/issues/1265.
+# Ensure that we can successfully track a `.bst` file that has comments inside
+# one of our YAML directives (like list append, prepend etc).
+@pytest.mark.datafiles(os.path.join(TOP_DIR, "source-track"))
+def test_track_with_comments(cli, datafiles):
+ project = str(datafiles)
+ generate_project(project, {"aliases": {"project-root": "file:///" + project}})
+
+ target = "comments.bst"
+
+ # Assert that it needs to be tracked
+ assert cli.get_element_state(project, target) == "no reference"
+
+ # Track and fetch the sources
+ result = cli.run(project=project, args=["source", "track", target])
+ result.assert_success()
+ result = cli.run(project=project, args=["source", "fetch", target])
+ result.assert_success()
+
+ # Assert that the sources are cached
+ assert cli.get_element_state(project, target) == "buildable"