Merge "Fix double quoting issue when writing localconf"

This commit is contained in:
Zuul 2019-04-05 12:13:30 +00:00 committed by Gerrit Code Review
commit a6e4e42fb3
2 changed files with 23 additions and 1 deletions

View File

@ -252,7 +252,11 @@ class LocalConf(object):
if localrc:
vg = VarGraph(localrc)
for k, v in vg.getVars():
self.localrc.append('{}="{}"'.format(k, v))
# Avoid double quoting
if len(v) and v[0]=='"':
self.localrc.append('{}={}'.format(k, v))
else:
self.localrc.append('{}="{}"'.format(k, v))
if k == 'LIBS_FROM_GIT':
lfg = True
elif k == 'TEMPEST_PLUGINS':

View File

@ -187,6 +187,24 @@ class TestDevstackLocalConf(unittest.TestCase):
lfg = line.strip().split('=')[1]
self.assertEqual('"oslo.db"', lfg)
def test_avoid_double_quote(self):
"Test that there a no duplicated quotes"
localrc = {'TESTVAR': '"quoted value"'}
p = dict(localrc=localrc,
base_services=[],
base_dir='./test',
path=os.path.join(self.tmpdir, 'test.local.conf'),
projects={})
lc = self._init_localconf(p)
lc.write(p['path'])
testvar = None
with open(p['path']) as f:
for line in f:
if line.startswith('TESTVAR'):
testvar = line.strip().split('=')[1]
self.assertEqual('"quoted value"', testvar)
def test_plugin_circular_deps(self):
"Test that plugins with circular dependencies fail"
os.makedirs(os.path.join(self.tmpdir, 'foo-plugin', 'devstack'))