REGRESSION (r229955): run-webkit-tests runs tests in skipped directories and subdirectories of directory given on command line
https://bugs.webkit.org/show_bug.cgi?id=185054
<rdar://problem/39773209>

Reviewed by Ryosuke Niwa.

Fallback to MacPort.CURRENT_VERSION if we are not using a known named macOS and do not have Apple Additions.

Darwin-based ports have OS version-specific test expectations and are certified to support running tests using
the currently shipping OS by way of a hardcoded class variable CURRENT_VERSION. The run-webkit-tests script
depends on the OS version to find the applicable TestExpectations files to parse to compute the list of skipped
tests for the port.

* Scripts/webkitpy/port/mac.py:
(MacPort.__init__): Fall back to MacPort.CURRENT_VERSION if we are not using a known named macOS and do not
have Apple Additions.
* Scripts/webkitpy/port/mac_unittest.py:
(MacTest.test_factory_with_future_version): Added.
(MacTest.test_factory_with_future_version_and_apple_additions): Renamed from MacTest.test_factory_with_future_version()
and added code to use the mock Apple Additions so that running this code with- and without- the real Apple Additions
produces consistent results now that the Mac port's OS version falls back to MacPort.CURRENT_VERSION when Apple Additions
is absent.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 11f4265..665fcfba 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,28 @@
+2018-05-07  Daniel Bates  <dabates@apple.com>
+
+        REGRESSION (r229955): run-webkit-tests runs tests in skipped directories and subdirectories of directory given on command line
+        https://bugs.webkit.org/show_bug.cgi?id=185054
+        <rdar://problem/39773209>
+
+        Reviewed by Ryosuke Niwa.
+
+        Fallback to MacPort.CURRENT_VERSION if we are not using a known named macOS and do not have Apple Additions.
+
+        Darwin-based ports have OS version-specific test expectations and are certified to support running tests using
+        the currently shipping OS by way of a hardcoded class variable CURRENT_VERSION. The run-webkit-tests script
+        depends on the OS version to find the applicable TestExpectations files to parse to compute the list of skipped
+        tests for the port.
+
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort.__init__): Fall back to MacPort.CURRENT_VERSION if we are not using a known named macOS and do not
+        have Apple Additions.
+        * Scripts/webkitpy/port/mac_unittest.py:
+        (MacTest.test_factory_with_future_version): Added.
+        (MacTest.test_factory_with_future_version_and_apple_additions): Renamed from MacTest.test_factory_with_future_version()
+        and added code to use the mock Apple Additions so that running this code with- and without- the real Apple Additions
+        produces consistent results now that the Mac port's OS version falls back to MacPort.CURRENT_VERSION when Apple Additions
+        is absent.
+
 2018-05-07  Brian Burg  <bburg@apple.com>
 
         Web Inspector: opt out of process swap on navigation if a Web Inspector frontend is connected
diff --git a/Tools/Scripts/webkitpy/port/mac.py b/Tools/Scripts/webkitpy/port/mac.py
index 710a810..f2d761e 100644
--- a/Tools/Scripts/webkitpy/port/mac.py
+++ b/Tools/Scripts/webkitpy/port/mac.py
@@ -60,7 +60,7 @@
         split_port_name = port_name.split('-')
         if len(split_port_name) > 1 and split_port_name[1] != 'wk2':
             self._os_version = version_name_map.from_name(split_port_name[1])[1]
-        elif self.host.platform.is_mac():
+        elif self.host.platform.is_mac() and apple_additions():
             self._os_version = self.host.platform.os_version
         if not self._os_version:
             self._os_version = MacPort.CURRENT_VERSION
diff --git a/Tools/Scripts/webkitpy/port/mac_unittest.py b/Tools/Scripts/webkitpy/port/mac_unittest.py
index 97ba5c1..0e66ac8 100644
--- a/Tools/Scripts/webkitpy/port/mac_unittest.py
+++ b/Tools/Scripts/webkitpy/port/mac_unittest.py
@@ -34,6 +34,7 @@
 from webkitpy.tool.mocktool import MockOptions
 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, ScriptError
 from webkitpy.common.version import Version
+from webkitpy.common.version_name_map import VersionNameMap
 
 
 class MacTest(darwin_testcase.DarwinTest):
@@ -159,19 +160,37 @@
     def test_factory_with_future_version(self):
         port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac')
         self.assertEqual(port.driver_name(), 'WebKitTestRunner')
-        self.assertEqual(port.version_name(), None)
+        self.assertEqual(port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name))
 
         port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac')
         self.assertEqual(port.driver_name(), 'DumpRenderTree')
-        self.assertEqual(port.version_name(), None)
+        self.assertEqual(port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name))
 
         port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2')
         self.assertEqual(port.driver_name(), 'WebKitTestRunner')
-        self.assertEqual(port.version_name(), None)
+        self.assertEqual(port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name))
 
         port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2')
         self.assertEqual(port.driver_name(), 'WebKitTestRunner')
-        self.assertEqual(port.version_name(), None)
+        self.assertEqual(port.version_name(), VersionNameMap().to_name(MacPort.CURRENT_VERSION, platform=MacPort.port_name))
+
+    def test_factory_with_future_version_and_apple_additions(self):
+        with port_testcase.bind_mock_apple_additions():
+            port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac')
+            self.assertEqual(port.driver_name(), 'WebKitTestRunner')
+            self.assertEqual(port.version_name(), None)
+
+            port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac')
+            self.assertEqual(port.driver_name(), 'DumpRenderTree')
+            self.assertEqual(port.version_name(), None)
+
+            port = self.make_port(options=MockOptions(webkit_test_runner=False), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2')
+            self.assertEqual(port.driver_name(), 'WebKitTestRunner')
+            self.assertEqual(port.version_name(), None)
+
+            port = self.make_port(options=MockOptions(webkit_test_runner=True), os_version=MacTest.FUTURE_VERSION, os_name='mac', port_name='mac-wk2')
+            self.assertEqual(port.driver_name(), 'WebKitTestRunner')
+            self.assertEqual(port.version_name(), None)
 
     def test_factory_with_portname_version(self):
         port = self.make_port(options=MockOptions(webkit_test_runner=False), port_name='mac-mountainlion')