Report dynamic layout config errors
If Zuul encounters a syntax error when loading an in-repo layout,
report that as a failure on the change. Try to provide as much
readable information as possible to allow the user to diagnose the
error.
All top-level configuration objects are updated to support a hidden
source context variable to aid in creating a useful error message.
Item.areAllJobsComplete is updated so that it returns true in the
case of a merge failure or config error. In Zuulv2, we knew what
jobs we would run even in those cases, but in Zuulv3, we don't, so
the item does not have a job tree, so in those cases, the item does
not report that all jobs are complete. Returining True in this case
allows the NNFI algorithm to continue and expel the item from the
queue, avoiding an inifinite loop.
The merge failure accessor method is simplified.
Change-Id: I9cf19b87c6af5926b5e8bb403b81ce0470e3592d
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index f69ffe6..cf88265 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -185,6 +185,27 @@
dict(name='project-test1', result='SUCCESS', changes='2,1'),
dict(name='project-test2', result='SUCCESS', changes='3,1')])
+ def test_dynamic_syntax_error(self):
+ in_repo_conf = textwrap.dedent(
+ """
+ - job:
+ name: project-test2
+ foo: error
+ """)
+
+ file_dict = {'.zuul.yaml': in_repo_conf}
+ A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+ files=file_dict)
+ A.addApproval('code-review', 2)
+ self.fake_gerrit.addEvent(A.addApproval('approved', 1))
+ self.waitUntilSettled()
+
+ self.assertEqual(A.data['status'], 'NEW')
+ self.assertEqual(A.reported, 2,
+ "A should report start and failure")
+ self.assertIn('syntax error', A.messages[1],
+ "A should have a syntax error reported")
+
class TestAnsible(AnsibleZuulTestCase):
# A temporary class to hold new tests while others are disabled