| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Platform-specific utility methods shared by several scripts.""" | 6 """Platform-specific utility methods shared by several scripts.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import signal | 10 import signal |
| 11 import subprocess | 11 import subprocess |
| 12 import sys | 12 import sys |
| 13 import logging | 13 import logging |
| 14 | 14 |
| 15 import google.path_utils | 15 import google.path_utils |
| 16 | 16 |
| 17 # Distinguish the path_utils.py in this dir from google.path_utils. | 17 # Distinguish the path_utils.py in this dir from google.path_utils. |
| 18 import path_utils as layout_package_path_utils | 18 import path_utils as layout_package_path_utils |
| 19 | 19 |
| 20 # This will be a native path to the directory this file resides in. | 20 # This will be a native path to the directory this file resides in. |
| 21 # It can either be relative or absolute depending how it's executed. | 21 # It can either be relative or absolute depending how it's executed. |
| 22 THISDIR = os.path.dirname(os.path.abspath(__file__)) | 22 THISDIR = os.path.dirname(os.path.abspath(__file__)) |
| 23 def PathFromBase(*pathies): | 23 def PathFromBase(*pathies): |
| 24 return google.path_utils.FindUpward(THISDIR, *pathies) | 24 return google.path_utils.FindUpward(THISDIR, *pathies) |
| 25 | 25 |
| 26 def PathFromBuildResults(*pathies): |
| 27 # FIXME(dkegel): use latest or warn if more than one found? |
| 28 for dir in ["sconsbuild", "out", "xcodebuild"]: |
| 29 try: |
| 30 return google.path_utils.FindUpward(THISDIR, dir, *pathies) |
| 31 except: |
| 32 pass |
| 33 raise google.path_utils.PathNotFound("Unable to find %s under any ancestor of
%s" % (os.path.join(*pathies), THISDIR)) |
| 34 |
| 26 def IsNonWindowsPlatformTargettingWindowsResults(): | 35 def IsNonWindowsPlatformTargettingWindowsResults(): |
| 27 """Returns true iff this platform is targetting Windows baseline, but isn't | 36 """Returns true iff this platform is targetting Windows baseline, but isn't |
| 28 Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to | 37 Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to |
| 29 be targetting Mac.""" | 38 be targetting Mac.""" |
| 30 return True | 39 return True |
| 31 | 40 |
| 32 def GetTestListPlatformName(): | 41 def GetTestListPlatformName(): |
| 33 """Returns the name we use to identify the platform in the layout test | 42 """Returns the name we use to identify the platform in the layout test |
| 34 test list files.""" | 43 test list files.""" |
| 35 return "LINUX" | 44 return "LINUX" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 os.kill(server_process.pid, signal.SIGTERM) | 164 os.kill(server_process.pid, signal.SIGTERM) |
| 156 | 165 |
| 157 def WDiffExecutablePath(self): | 166 def WDiffExecutablePath(self): |
| 158 """Path to the WDiff executable, which we assume is already installed and | 167 """Path to the WDiff executable, which we assume is already installed and |
| 159 in the user's $PATH. | 168 in the user's $PATH. |
| 160 """ | 169 """ |
| 161 return 'wdiff' | 170 return 'wdiff' |
| 162 | 171 |
| 163 def ImageCompareExecutablePath(self, target): | 172 def ImageCompareExecutablePath(self, target): |
| 164 """Path to the image_diff binary.""" | 173 """Path to the image_diff binary.""" |
| 165 return PathFromBase('sconsbuild', target, 'image_diff') | 174 return PathFromBuildResults(target, 'image_diff') |
| 166 | 175 |
| 167 def TestShellBinary(self): | 176 def TestShellBinary(self): |
| 168 """The name of the binary for TestShell.""" | 177 """The name of the binary for TestShell.""" |
| 169 return 'test_shell' | 178 return 'test_shell' |
| 170 | 179 |
| 171 def TestShellBinaryPath(self, target): | 180 def TestShellBinaryPath(self, target): |
| 172 """Return the platform-specific binary path for our TestShell. | 181 """Return the platform-specific binary path for our TestShell. |
| 173 | 182 |
| 174 Args: | 183 Args: |
| 175 target: Build target mode (debug or release) | 184 target: Build target mode (debug or release) |
| 176 """ | 185 """ |
| 177 | 186 |
| 178 if target in ('Debug', 'Release'): | 187 if target in ('Debug', 'Release'): |
| 179 try: | 188 try: |
| 180 debug_path = PathFromBase('sconsbuild', 'Debug', self.TestShellBinary()) | 189 debug_path = PathFromBuildResults('Debug', self.TestShellBinary()) |
| 181 release_path = PathFromBase('sconsbuild', 'Release', \ | 190 release_path = PathFromBuildResults('Release', \ |
| 182 self.TestShellBinary()) | 191 self.TestShellBinary()) |
| 183 | 192 |
| 184 debug_mtime = os.stat(debug_path).st_mtime | 193 debug_mtime = os.stat(debug_path).st_mtime |
| 185 release_mtime = os.stat(release_path).st_mtime | 194 release_mtime = os.stat(release_path).st_mtime |
| 186 | 195 |
| 187 if debug_mtime > release_mtime and target == 'Release' or \ | 196 if debug_mtime > release_mtime and target == 'Release' or \ |
| 188 release_mtime > debug_mtime and target == 'Debug': | 197 release_mtime > debug_mtime and target == 'Debug': |
| 189 logging.info('\x1b[31mWarning: you are not running the most ' + \ | 198 logging.info('\x1b[31mWarning: you are not running the most ' + \ |
| 190 'recent test_shell binary. You need to pass ' + \ | 199 'recent test_shell binary. You need to pass ' + \ |
| 191 '--debug or not to select between Debug and ' + \ | 200 '--debug or not to select between Debug and ' + \ |
| 192 'Release.\x1b[0m') | 201 'Release.\x1b[0m') |
| 193 # This will fail if we don't have both a debug and release binary. | 202 # This will fail if we don't have both a debug and release binary. |
| 194 # That's fine because, in this case, we must already be running the | 203 # That's fine because, in this case, we must already be running the |
| 195 # most up-to-date one. | 204 # most up-to-date one. |
| 196 except OSError: | 205 except OSError: |
| 197 pass | 206 pass |
| 198 except google.path_utils.PathNotFound: | 207 except google.path_utils.PathNotFound: |
| 199 pass | 208 pass |
| 200 | 209 |
| 201 return PathFromBase('sconsbuild', target, self.TestShellBinary()) | 210 return PathFromBuildResults(target, self.TestShellBinary()) |
| 202 | 211 |
| 203 def FuzzyMatchBinaryPath(self): | 212 def FuzzyMatchBinaryPath(self): |
| 204 """Return the path to the fuzzy matcher binary.""" | 213 """Return the path to the fuzzy matcher binary.""" |
| 205 return PathFromBase('third_party', 'fuzzymatch', 'fuzzymatch') | 214 return PathFromBase('third_party', 'fuzzymatch', 'fuzzymatch') |
| 206 | 215 |
| 207 def TestListPlatformDir(self): | 216 def TestListPlatformDir(self): |
| 208 """Return the platform-specific directory for where the test lists live""" | 217 """Return the platform-specific directory for where the test lists live""" |
| 209 return 'linux' | 218 return 'linux' |
| 210 | 219 |
| 211 def PlatformDir(self): | 220 def PlatformDir(self): |
| 212 """Returns the most specific directory name where platform-specific | 221 """Returns the most specific directory name where platform-specific |
| 213 results live. | 222 results live. |
| 214 """ | 223 """ |
| 215 return 'chromium-linux' | 224 return 'chromium-linux' |
| 216 | 225 |
| 217 def PlatformNewResultsDir(self): | 226 def PlatformNewResultsDir(self): |
| 218 """Returns the directory name in which to output newly baselined tests. | 227 """Returns the directory name in which to output newly baselined tests. |
| 219 """ | 228 """ |
| 220 return self.PlatformDir() | 229 return self.PlatformDir() |
| OLD | NEW |