Skip to content

Commit c4b19ca

Browse files
authored
Merge pull request swiftlang#36790 from porglezomp-misc/patch-patch-patch
[build-script] Support 5-component Swift versions
2 parents 4175f0d + 7ed0023 commit c4b19ca

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

utils/build_swift/build_swift/argparse/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ class SwiftVersionType(RegexType):
157157
"""Argument type used to validate Swift version strings.
158158
"""
159159

160-
ERROR_MESSAGE = ('Invalid version value, must be "MAJOR.MINOR" '
161-
', "MAJOR.MINOR.PATCH" or "MAJOR.MINOR.PATCH.PATCH"')
162-
VERSION_REGEX = r'^(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?$'
160+
ERROR_MESSAGE = ('Invalid version value, must be "MAJOR.MINOR"'
161+
', "MAJOR.MINOR.PATCH", "MAJOR.MINOR.PATCH.PATCH"'
162+
', or "MAJOR.MINOR.PATCH.PATCH.PATCH".')
163+
VERSION_REGEX = r'^(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?(\.(\d+))?$'
163164

164165
def __init__(self):
165166
super(SwiftVersionType, self).__init__(

utils/build_swift/tests/build_swift/argparse/test_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,17 @@ def test_valid_swift_version(self):
192192
self.assertIsInstance(version, Version)
193193
self.assertEqual(version.components, (100, 0, 999, 1))
194194

195+
version = swift_version_type('5.4.0.300.205')
196+
self.assertIsInstance(version, Version)
197+
self.assertEqual(version.components, (5, 4, 0, 300, 205))
198+
195199
def test_invalid_swift_version(self):
196200
swift_version_type = types.SwiftVersionType()
197201

198202
with self.assertRaises(ArgumentTypeError):
199203
swift_version_type('2')
200-
swift_version_type('1.8.0.2.3')
201-
swift_version_type('100.0.56.1.85')
204+
swift_version_type('1.8.0.2.3.1')
205+
swift_version_type('100.0.56.1.85.1')
202206

203207

204208
class TestShellSplitType(unittest.TestCase):

0 commit comments

Comments
 (0)