1 # Copyright (C) 2011 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
13 # * Neither the Google name nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 from webkitpy.layout_tests.port.webkit import WebKitPort
32 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
35 _log = logging.getLogger(__name__)
38 class ApplePort(WebKitPort):
39 """Shared logic between all of Apple's ports."""
41 # This is used to represent the version of an operating system
42 # corresponding to the "mac" or "win" base LayoutTests/platform
43 # directory. I'm not sure this concept is very useful,
44 # but it gives us a way to refer to fallback paths *only* including
46 # This is mostly done because TestConfiguration assumes that self.version()
47 # will never return None. (None would be another way to represent this concept.)
48 # Apple supposedly has explicit "future" results which are kept in an internal repository.
49 # It's possible that Apple would want to fix this code to work better with those results.
50 FUTURE_VERSION = 'future' # FIXME: This whole 'future' thing feels like a hack.
52 def _strip_port_name_prefix(self, port_name):
53 # Callers treat this return value as the "version", which only works
54 # because Apple ports use a simple name-version port_name scheme.
55 # FIXME: This parsing wouldn't be needed if port_name handling was moved to factory.py
56 # instead of the individual port constructors.
57 return port_name[len(self.port_name + '-'):]
59 def __init__(self, port_name=None, os_version_string=None, **kwargs):
60 port_name = port_name or self.port_name
61 WebKitPort.__init__(self, port_name=port_name, **kwargs)
63 # FIXME: This sort of parsing belongs in factory.py!
64 if port_name == '%s-wk2' % self.port_name:
65 port_name = self.port_name
66 # FIXME: This may be wrong, since options is a global property, and the port_name is specific to this object?
67 self.set_option_default('webkit_test_runner', True)
69 if port_name == self.port_name:
70 self._version = self._detect_version(os_version_string) or self.FUTURE_VERSION
71 self._name = self.port_name + '-' + self._version
73 assert port_name in self.VERSION_FALLBACK_ORDER, "%s is not in %s" % (port_name, self.VERSION_FALLBACK_ORDER)
74 self._version = self._strip_port_name_prefix(port_name)
76 # FIXME: A more sophisitcated version of this function should move to WebKitPort and replace all calls to name().
77 def _port_name_with_version(self):
78 components = [self.port_name]
79 if self._version != self.FUTURE_VERSION:
80 components.append(self._version)
81 return '-'.join(components)
83 def _generate_all_test_configurations(self):
85 for port_name in self.VERSION_FALLBACK_ORDER:
87 version = self._strip_port_name_prefix(port_name)
89 # The version for the "base" port is currently defined as "future"
90 # since TestConfiguration doesn't allow None as a valid version.
91 version = self.FUTURE_VERSION
93 for build_type in self.ALL_BUILD_TYPES:
94 # Win and Mac ports both happen to only exist on x86 architectures and always use cpu graphics (gpu graphics is a chromium-only hack).
95 # But at some later point we may need to make these configurable by the MacPort and WinPort subclasses.
96 configurations.append(TestConfiguration(version=version, architecture='x86', build_type=build_type, graphics_type='cpu'))