Merge "Handle zuul.yaml files with only comments"

This commit is contained in:
Zuul 2023-05-22 12:45:55 +00:00 committed by Gerrit Code Review
commit bb01c1613f
7 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,2 @@
- hosts: all
tasks: []

View File

@ -0,0 +1 @@
# test comment

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,8 @@
- tenant:
name: tenant-one
source:
gerrit:
config-projects:
- common-config
untrusted-projects:
- org/project

View File

@ -1318,6 +1318,18 @@ class TestCentralJobs(ZuulTestCase):
self._test_central_template_on_branch('stable', 'master')
class TestEmptyConfigFile(ZuulTestCase):
tenant_config_file = 'config/empty-config-file/main.yaml'
def test_empty_config_file(self):
# Tests that a config file with only comments does not cause
# an error.
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEquals(
len(tenant.layout.loading_errors), 0,
"No error should have been accumulated")
class TestInRepoConfig(ZuulTestCase):
# A temporary class to hold new tests while others are disabled

View File

@ -7694,6 +7694,10 @@ class UnparsedConfig(object):
return r
def extend(self, conf):
# conf might be None in the case of a file with only comments.
if conf is None:
return
if isinstance(conf, UnparsedConfig):
self.pragmas.extend(conf.pragmas)
self.pipelines.extend(conf.pipelines)