Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux.py

Issue 2143123004: Access environment variables through Host object instead of directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and updated after change for dummy home dir on linux. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import logging 29 import logging
30 import os
31 30
32 from webkitpy.layout_tests.breakpad.dump_reader_multipart import DumpReaderLinux 31 from webkitpy.layout_tests.breakpad.dump_reader_multipart import DumpReaderLinux
33 from webkitpy.layout_tests.port import base 32 from webkitpy.layout_tests.port import base
34 from webkitpy.layout_tests.port import win 33 from webkitpy.layout_tests.port import win
35 34
36 35
37 _log = logging.getLogger(__name__) 36 _log = logging.getLogger(__name__)
38 37
39 38
40 class LinuxPort(base.Port): 39 class LinuxPort(base.Port):
(...skipping 18 matching lines...) Expand all
59 return port_name 58 return port_name
60 59
61 def __init__(self, host, port_name, **kwargs): 60 def __init__(self, host, port_name, **kwargs):
62 super(LinuxPort, self).__init__(host, port_name, **kwargs) 61 super(LinuxPort, self).__init__(host, port_name, **kwargs)
63 self._version = port_name[port_name.index('linux-') + len('linux-'):] 62 self._version = port_name[port_name.index('linux-') + len('linux-'):]
64 self._architecture = "x86_64" 63 self._architecture = "x86_64"
65 assert self._version in self.SUPPORTED_VERSIONS 64 assert self._version in self.SUPPORTED_VERSIONS
66 65
67 if not self.get_option('disable_breakpad'): 66 if not self.get_option('disable_breakpad'):
68 self._dump_reader = DumpReaderLinux(host, self._build_path()) 67 self._dump_reader = DumpReaderLinux(host, self._build_path())
69 68 self._original_home = None
70 self._original_home = os.environ['HOME']
71 self._dummy_home = None
72 69
73 def additional_driver_flag(self): 70 def additional_driver_flag(self):
74 flags = super(LinuxPort, self).additional_driver_flag() 71 flags = super(LinuxPort, self).additional_driver_flag()
75 if not self.get_option('disable_breakpad'): 72 if not self.get_option('disable_breakpad'):
76 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()] 73 flags += ['--enable-crash-reporter', '--crash-dumps-dir=%s' % self._ dump_reader.crash_dumps_directory()]
77 return flags 74 return flags
78 75
79 def check_build(self, needs_http, printer): 76 def check_build(self, needs_http, printer):
80 result = super(LinuxPort, self).check_build(needs_http, printer) 77 result = super(LinuxPort, self).check_build(needs_http, printer)
81 78
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 # PROTECTED METHODS 115 # PROTECTED METHODS
119 # 116 #
120 117
121 def _setup_dummy_home_dir(self): 118 def _setup_dummy_home_dir(self):
122 """Creates a dummy home directory for running the test. 119 """Creates a dummy home directory for running the test.
123 120
124 This is a workaround for crbug.com/595504; see crbug.com/612730. 121 This is a workaround for crbug.com/595504; see crbug.com/612730.
125 If crbug.com/612730 is resolved in another way, then this may be 122 If crbug.com/612730 is resolved in another way, then this may be
126 unnecessary. 123 unnecessary.
127 """ 124 """
125 self._original_home = self.host.environ.get('HOME')
128 dummy_home = str(self._filesystem.mkdtemp()) 126 dummy_home = str(self._filesystem.mkdtemp())
129 os.environ['HOME'] = dummy_home 127 self.host.environ['HOME'] = dummy_home
130 self._copy_files_to_dummy_home_dir(dummy_home) 128 self._copy_files_to_dummy_home_dir(dummy_home)
131 129
132 def _copy_files_to_dummy_home_dir(self, dummy_home): 130 def _copy_files_to_dummy_home_dir(self, dummy_home):
133 # Note: This may be unnecessary. 131 # Note: This may be unnecessary.
134 fs = self._filesystem 132 fs = self._filesystem
135 for filename in ['.Xauthority']: 133 for filename in ['.Xauthority']:
136 original_path = fs.join(self._original_home, filename) 134 original_path = fs.join(self._original_home, filename)
137 if not fs.exists(original_path): 135 if not fs.exists(original_path):
138 continue 136 continue
139 fs.copyfile(original_path, fs.join(dummy_home, filename)) 137 fs.copyfile(original_path, fs.join(dummy_home, filename))
140 138
141 def _clean_up_dummy_home_dir(self): 139 def _clean_up_dummy_home_dir(self):
142 """Cleans up the dummy dir and resets the HOME environment variable.""" 140 """Cleans up the dummy dir and resets the HOME environment variable."""
143 dummy_home = os.environ['HOME'] 141 dummy_home = self.host.environ['HOME']
144 assert dummy_home != self._original_home 142 assert dummy_home != self._original_home
145 self._filesystem.rmtree(dummy_home) 143 self._filesystem.rmtree(dummy_home)
146 os.environ['HOME'] = self._original_home 144 self.host.environ['HOME'] = self._original_home
147 145
148 def _check_apache_install(self): 146 def _check_apache_install(self):
149 result = self._check_file_exists(self.path_to_apache(), "apache2") 147 result = self._check_file_exists(self.path_to_apache(), "apache2")
150 result = self._check_file_exists(self.path_to_apache_config_file(), "apa che2 config file") and result 148 result = self._check_file_exists(self.path_to_apache_config_file(), "apa che2 config file") and result
151 if not result: 149 if not result:
152 _log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"') 150 _log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"')
153 _log.error('') 151 _log.error('')
154 return result 152 return result
155 153
156 def _wdiff_missing_message(self): 154 def _wdiff_missing_message(self):
157 return 'wdiff is not installed; please install using "sudo apt-get insta ll wdiff"' 155 return 'wdiff is not installed; please install using "sudo apt-get insta ll wdiff"'
158 156
159 def _path_to_driver(self, target=None): 157 def _path_to_driver(self, target=None):
160 binary_name = self.driver_name() 158 binary_name = self.driver_name()
161 return self._build_path_with_target(target, binary_name) 159 return self._build_path_with_target(target, binary_name)
162 160
163 def _path_to_helper(self): 161 def _path_to_helper(self):
164 return None 162 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698