Skip to content

Commit ef2c448

Browse files
authored
Merge pull request #29406 from Rostepher/longer-swift-version-support
[Build System: build-script] Support Swift versions with up to four version components, matching Clang.
2 parents 2196eb3 + cc9ff6a commit ef2c448

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

utils/build_swift/build_swift/argparse/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class SwiftVersionType(RegexType):
158158
"""
159159

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

164164
def __init__(self):
165165
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
@@ -188,13 +188,17 @@ def test_valid_swift_version(self):
188188
swift_version_type('200.0.56')
189189
swift_version_type('100000.0.1')
190190

191+
version = swift_version_type('100.0.999.1')
192+
self.assertIsInstance(version, Version)
193+
self.assertEqual(version.components, (100, 0, 999, 1))
194+
191195
def test_invalid_swift_version(self):
192196
swift_version_type = types.SwiftVersionType()
193197

194198
with self.assertRaises(ArgumentTypeError):
195199
swift_version_type('2')
196-
swift_version_type('1.8.0.2')
197-
swift_version_type('100.0.56.1')
200+
swift_version_type('1.8.0.2.3')
201+
swift_version_type('100.0.56.1.85')
198202

199203

200204
class TestShellSplitType(unittest.TestCase):

0 commit comments

Comments
 (0)