apple.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright (C) 2011 Google Inc. All rights reserved.
  2. #
  3. # Redistribution and use in source and binary forms, with or without
  4. # modification, are permitted provided that the following conditions are
  5. # met:
  6. #
  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
  12. # distribution.
  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.
  16. #
  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.
  28. import logging
  29. from webkitpy.port.base import Port
  30. from webkitpy.layout_tests.models.test_configuration import TestConfiguration
  31. _log = logging.getLogger(__name__)
  32. class ApplePort(Port):
  33. """Shared logic between all of Apple's ports."""
  34. # This is used to represent the version of an operating system
  35. # corresponding to the "mac" or "win" base LayoutTests/platform
  36. # directory. I'm not sure this concept is very useful,
  37. # but it gives us a way to refer to fallback paths *only* including
  38. # the base directory.
  39. # This is mostly done because TestConfiguration assumes that self.version()
  40. # will never return None. (None would be another way to represent this concept.)
  41. # Apple supposedly has explicit "future" results which are kept in an internal repository.
  42. # It's possible that Apple would want to fix this code to work better with those results.
  43. FUTURE_VERSION = 'future' # FIXME: This whole 'future' thing feels like a hack.
  44. # overridden in subclasses
  45. VERSION_FALLBACK_ORDER = []
  46. ARCHITECTURES = []
  47. @classmethod
  48. def determine_full_port_name(cls, host, options, port_name):
  49. options = options or {}
  50. if port_name in (cls.port_name, cls.port_name + '-wk2'):
  51. # If the port_name matches the (badly named) cls.port_name, that
  52. # means that they passed 'mac' or 'win' and didn't specify a version.
  53. # That convention means that we're supposed to use the version currently
  54. # being run, so this won't work if you're not on mac or win (respectively).
  55. # If you're not on the o/s in question, you must specify a full version or -future (cf. above).
  56. assert host.platform.os_name in port_name, "%s is not in %s!" % (host.platform.os_name, port_name)
  57. if port_name == cls.port_name and not getattr(options, 'webkit_test_runner', False):
  58. port_name = cls.port_name + '-' + host.platform.os_version
  59. else:
  60. port_name = cls.port_name + '-' + host.platform.os_version + '-wk2'
  61. elif getattr(options, 'webkit_test_runner', False) and '-wk2' not in port_name:
  62. port_name += '-wk2'
  63. return port_name
  64. def _strip_port_name_prefix(self, port_name):
  65. # Callers treat this return value as the "version", which only works
  66. # because Apple ports use a simple name-version port_name scheme.
  67. # FIXME: This parsing wouldn't be needed if port_name handling was moved to factory.py
  68. # instead of the individual port constructors.
  69. return port_name[len(self.port_name + '-'):]
  70. def __init__(self, host, port_name, **kwargs):
  71. super(ApplePort, self).__init__(host, port_name, **kwargs)
  72. allowed_port_names = self.VERSION_FALLBACK_ORDER + [self.operating_system() + "-future"]
  73. port_name = port_name.replace('-wk2', '')
  74. self._version = self._strip_port_name_prefix(port_name)
  75. assert port_name in allowed_port_names, "%s is not in %s" % (port_name, allowed_port_names)
  76. def _skipped_file_search_paths(self):
  77. # We don't have a dedicated Skipped file for the most recent version of the port;
  78. # we just use the one in platform/{mac,win}
  79. most_recent_name = self.VERSION_FALLBACK_ORDER[-1]
  80. return set(filter(lambda name: name != most_recent_name, super(ApplePort, self)._skipped_file_search_paths()))
  81. # FIXME: A more sophisticated version of this function should move to WebKitPort and replace all calls to name().
  82. # This is also a misleading name, since 'mac-future' gets remapped to 'mac'.
  83. def _port_name_with_version(self):
  84. return self.name().replace('-future', '').replace('-wk2', '')
  85. def _generate_all_test_configurations(self):
  86. configurations = []
  87. allowed_port_names = self.VERSION_FALLBACK_ORDER + [self.operating_system() + "-future"]
  88. for port_name in allowed_port_names:
  89. for build_type in self.ALL_BUILD_TYPES:
  90. for architecture in self.ARCHITECTURES:
  91. configurations.append(TestConfiguration(version=self._strip_port_name_prefix(port_name), architecture=architecture, build_type=build_type))
  92. return configurations