webkitpy: Better name-version mapping (Part 1)
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Nov 2017 15:17:02 +0000 (15:17 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Nov 2017 15:17:02 +0000 (15:17 +0000)
commite7d405223e52fedb112e133951cc7c8d83fc2432
tree915aa951ef81abe7d84e76cdf51568c1d9201b7d
parent781b41d00cabfc2bd9805af893ad3869e784be9d
webkitpy: Better name-version mapping (Part 1)
https://bugs.webkit.org/show_bug.cgi?id=179621
<rdar://problem/35589585>

Reviewed by David Kilzer.

Mapping version numbers to version names should occur in a central location.
This has a few advantages. First, it makes iterating through versions easier.
Second, it allows for apple_additions to define an additional set of name
mappings. Lastly, it will allow, in a future patch, for us to track version
instead of version name, only mapping version to version name when required.

* Scripts/webkitpy/common/system/platforminfo.py:
(PlatformInfo.__init__):
(PlatformInfo._determine_os_name): Use VersionNameMap instead of custom functions
mapping version to name.
(PlatformInfo._determine_linux_version): Deleted.
(PlatformInfo._determine_mac_version): Deleted.
(PlatformInfo._determine_win_version): Deleted.
* Scripts/webkitpy/common/system/platforminfo_unittest.py:
(TestPlatformInfo.test_os_name_and_wrappers):
(TestPlatformInfo.test_os_version):
(TestPlatformInfo.test_display_name):
(TestPlatformInfo.test_total_bytes_memory):
* Scripts/webkitpy/common/version.py:
(Version.contained_in): Add partial version mapping.
* Scripts/webkitpy/common/version_name_map.py: Added.
(VersionNameMap): Holds a mapping of version name to version object.
(VersionNameMap.map): Don't re-create VersionNameMap every time.
(VersionNameMap.__init__): Initialize mapping, use platform to
define the default system platform.
(VersionNameMap._automap_to_major_version): Some operating systems, such
as iOS, have a naming scheme based on their major version and os name.
Automatically generate such mappings.
(VersionNameMap.to_name): Given a version object, platform name and
table, find the closest matching version name.
(VersionNameMap.strip_name_formatting): Remove spaces and extract the major version,
if a version string is included in the name.
(VersionNameMap.from_name): Return an os name and version given a version name.
* Scripts/webkitpy/common/version_name_map_unittest.py: Added.
(VersionMapTestCase):
(VersionMapTestCase.test_default_system_platform):
(VersionMapTestCase.test_mac_version_by_name):
(VersionMapTestCase.test_ios_version_by_name):
(VersionMapTestCase.test_mac_name_by_version):
(VersionMapTestCase.test_ios_name_by_version):
* Scripts/webkitpy/common/version_unittest.py:
(VersionTestCase.test_contained_in):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/platforminfo.py
Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py
Tools/Scripts/webkitpy/common/version.py
Tools/Scripts/webkitpy/common/version_name_map.py [new file with mode: 0644]
Tools/Scripts/webkitpy/common/version_name_map_unittest.py [new file with mode: 0644]
Tools/Scripts/webkitpy/common/version_unittest.py