• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright (C) 2010 Google Inc. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8#     * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10#     * Redistributions in binary form must reproduce the above
11# copyright notice, this list of conditions and the following disclaimer
12# in the documentation and/or other materials provided with the
13# distribution.
14
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
28def _test_expectations_overrides(port, super):
29    # The chrome ports use the regular overrides plus anything in the
30    # official test_expectations as well. Hopefully we don't get collisions.
31    chromium_overrides = super.test_expectations_overrides(port)
32
33    # FIXME: It used to be that AssertionError would get raised by
34    # path_from_chromium_base() if we weren't in a Chromium checkout, but
35    # this changed in r60427. This should probably be changed back.
36    overrides_path = port.path_from_chromium_base('webkit', 'tools',
37            'layout_tests', 'test_expectations_chrome.txt')
38    if not port._filesystem.exists(overrides_path):
39        return chromium_overrides
40
41    chromium_overrides = chromium_overrides or ''
42    return chromium_overrides + port._filesystem.read_text_file(overrides_path)
43
44def GetGoogleChromePort(**kwargs):
45    """Some tests have slightly different results when compiled as Google
46    Chrome vs Chromium.  In those cases, we prepend an additional directory to
47    to the baseline paths."""
48    # FIXME: This whole routine is a tremendous hack that needs to be cleaned up.
49
50    port_name = kwargs['port_name']
51    del kwargs['port_name']
52    if port_name == 'google-chrome-linux32':
53        import chromium_linux
54
55        class GoogleChromeLinux32Port(chromium_linux.ChromiumLinuxPort):
56            def baseline_search_path(self):
57                paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(
58                    self)
59                paths.insert(0, self._webkit_baseline_path(
60                    'google-chrome-linux32'))
61                return paths
62
63            def test_expectations_overrides(self):
64                return _test_expectations_overrides(self,
65                    chromium_linux.ChromiumLinuxPort)
66
67            def architecture(self):
68                return 'x86'
69
70        return GoogleChromeLinux32Port(port_name='chromium-linux-x86', **kwargs)
71    elif port_name == 'google-chrome-linux64':
72        import chromium_linux
73
74        class GoogleChromeLinux64Port(chromium_linux.ChromiumLinuxPort):
75            def baseline_search_path(self):
76                paths = chromium_linux.ChromiumLinuxPort.baseline_search_path(
77                    self)
78                paths.insert(0, self._webkit_baseline_path(
79                    'google-chrome-linux64'))
80                return paths
81
82            def test_expectations_overrides(self):
83                return _test_expectations_overrides(self,
84                    chromium_linux.ChromiumLinuxPort)
85
86            def architecture(self):
87                return 'x86_64'
88
89        # We use chromium-linux-x86 here in order to skip over the linux-x86_64
90        # baselines.
91        return GoogleChromeLinux64Port(port_name='chromium-linux-x86', **kwargs)
92    elif port_name.startswith('google-chrome-mac'):
93        import chromium_mac
94
95        class GoogleChromeMacPort(chromium_mac.ChromiumMacPort):
96            def baseline_search_path(self):
97                paths = chromium_mac.ChromiumMacPort.baseline_search_path(
98                    self)
99                paths.insert(0, self._webkit_baseline_path(
100                    'google-chrome-mac'))
101                return paths
102
103            def test_expectations_overrides(self):
104                return _test_expectations_overrides(self,
105                    chromium_mac.ChromiumMacPort)
106
107        return GoogleChromeMacPort(**kwargs)
108    elif port_name.startswith('google-chrome-win'):
109        import chromium_win
110
111        class GoogleChromeWinPort(chromium_win.ChromiumWinPort):
112            def baseline_search_path(self):
113                paths = chromium_win.ChromiumWinPort.baseline_search_path(
114                    self)
115                paths.insert(0, self._webkit_baseline_path(
116                    'google-chrome-win'))
117                return paths
118
119            def test_expectations_overrides(self):
120                return _test_expectations_overrides(self,
121                    chromium_win.ChromiumWinPort)
122
123        return GoogleChromeWinPort(**kwargs)
124    raise NotImplementedError('unsupported port: %s' % port_name)
125