Report job shadow errors to users
The Layout.addJob() method can raise an exception if the job definition shadows a definition in another repo. Instead of reporting that as "Unknown configuration error", give it the full Zuul syntax error treatment. This wraps the JobParser in two context managers each of which can raise a ConfigurationSyntaxError, so make sure that if the outer one sees such an error from the inner one, it simply passes it through. Change-Id: I7c6d5c6fa9d6d9329a53cdd98c1e3c38683b38af
This commit is contained in:
@@ -308,6 +308,26 @@ class TestInRepoConfig(ZuulTestCase):
|
||||
self.assertIn('syntax error', A.messages[1],
|
||||
"A should have a syntax error reported")
|
||||
|
||||
def test_untrusted_shadow_error(self):
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
- job:
|
||||
name: common-config-test
|
||||
""")
|
||||
|
||||
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('not permitted to shadow', A.messages[1],
|
||||
"A should have a syntax error reported")
|
||||
|
||||
|
||||
class TestAnsible(AnsibleZuulTestCase):
|
||||
# A temporary class to hold new tests while others are disabled
|
||||
|
||||
Reference in New Issue
Block a user