Merge "Support cloning one freeze to multiple"

This commit is contained in:
Zuul 2018-07-16 15:56:31 +00:00 committed by Gerrit Code Review
commit e9dcbceeba
2 changed files with 30 additions and 10 deletions

View File

@ -139,12 +139,12 @@ def _clone_versions(freezes, options):
for freeze_data in freezes:
versions = [v for v, d in freezes]
version, freeze = freeze_data
if (version in options.version_map and
options.version_map[version] not in versions):
print("Duplicating %s freeze to %s" %
(version, options.version_map[version]),
file=sys.stderr)
freezes.append((options.version_map[version], copy.copy(freeze)))
if version in options.version_map:
for dst_version in sorted(options.version_map[version]):
if dst_version not in versions:
print("Duplicating %s freeze to %s" %
(version, dst_version), file=sys.stderr)
freezes.append((dst_version, copy.copy(freeze)))
# -- untested UI glue from here down.
@ -177,7 +177,8 @@ def _validate_options(options):
"Invalid version-map entry %(map_entry)s"
% dict(map_entry=map_entry))
src, dst = map_entry.split(':')
version_map[src] = dst
version_map.setdefault(src, set())
version_map[src].add(dst)
options.version_map = version_map

View File

@ -110,7 +110,8 @@ class TestClone(testtools.TestCase):
def test_py34_clone_py35(self):
# Simulate an environment where we have python 3.4 data and need to
# clone that to python 3.5
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'})
options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
@ -125,7 +126,8 @@ class TestClone(testtools.TestCase):
def test_py34_noclone_py35(self):
# Simulate an environment where we have python 3.4 and python 3.5 data
# so there is no need to clone.
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'})
options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('other-pkg', '1.0.0')])
@ -140,7 +142,8 @@ class TestClone(testtools.TestCase):
def test_py35_clone_py34(self):
# Simulate an environment where we have python 3.5 data and need to
# clone that to python 3.4
options = Namespace(version_map={'3.4': '3.5', '3.5': '3.4'})
options = Namespace(version_map={'3.4': set(['3.5']),
'3.5': set(['3.4'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
@ -151,3 +154,19 @@ class TestClone(testtools.TestCase):
generate._clone_versions(freezes, options)
self.assertEqual(expected_freezes, freezes)
def test_py35_clone_py34_py36(self):
# Simulate an environment where we have python 3.5 data and need to
# clone that to python 3.4
options = Namespace(version_map={'3.5': set(['3.4', '3.6'])})
freeze_27 = ('2.7', [('dnspython', '1.15.0')])
freeze_34 = ('3.4', [('dnspython3', '1.12.0')])
freeze_35 = ('3.5', [('dnspython3', '1.12.0')])
freeze_36 = ('3.6', [('dnspython3', '1.12.0')])
freezes = [freeze_27, freeze_35]
expected_freezes = [freeze_27, freeze_35, freeze_34, freeze_36]
generate._clone_versions(freezes, options)
self.assertEqual(expected_freezes, freezes)