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

Side by Side Diff: webkit/tools/layout_tests/layout_package/path_utils.py

Issue 146112: Allow layout tests to be located both in src/webkit/data/layout_tests and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Some utility methods for getting paths used by run_webkit_tests.py. 5 """Some utility methods for getting paths used by run_webkit_tests.py.
6 """ 6 """
7 7
8 import errno 8 import errno
9 import os 9 import os
10 import platform_utils 10 import platform_utils
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 13
14 import google.path_utils 14 import google.path_utils
15 15
16 16
17 class PathNotFound(Exception): pass 17 class PathNotFound(Exception): pass
18 18
19 # Save some paths here so we don't keep re-evaling. 19 # Save some paths here so we don't keep re-evaling.
20 _webkit_root = None 20 _webkit_root = None
21 _layout_data_dir = None 21 _layout_data_dir = None
22 _layout_tests_dir = None
22 # A map from platform description to directory list. 23 # A map from platform description to directory list.
23 _platform_results_dirs = {} 24 _platform_results_dirs = {}
24 25
25 # An instance of the PlatformUtility for use by methods mapped from there. 26 # An instance of the PlatformUtility for use by methods mapped from there.
26 _platform_util = None 27 _platform_util = None
27 28
28 # TODO this should probably be moved into path_utils as ToUnixPath(). 29 # TODO this should probably be moved into path_utils as ToUnixPath().
29 def WinPathToUnix(path): 30 def WinPathToUnix(path):
30 """Convert a windows path to use unix-style path separators (a/b/c).""" 31 """Convert a windows path to use unix-style path separators (a/b/c)."""
31 return path.replace('\\', '/') 32 return path.replace('\\', '/')
(...skipping 12 matching lines...) Expand all
44 def LayoutDataDir(): 45 def LayoutDataDir():
45 """Gets the full path to the tests directory. Raises PathNotFound if 46 """Gets the full path to the tests directory. Raises PathNotFound if
46 we're unable to find it.""" 47 we're unable to find it."""
47 global _layout_data_dir 48 global _layout_data_dir
48 if _layout_data_dir: 49 if _layout_data_dir:
49 return _layout_data_dir 50 return _layout_data_dir
50 _layout_data_dir = google.path_utils.FindUpward(WebKitRoot(), 'webkit', 51 _layout_data_dir = google.path_utils.FindUpward(WebKitRoot(), 'webkit',
51 'data', 'layout_tests') 52 'data', 'layout_tests')
52 return _layout_data_dir 53 return _layout_data_dir
53 54
55 def LayoutTestsDir(path = None):
56 """Returns the full path to the directory containing layout tests, based on
57 the supplied relative or absolute path to a layout tests. If the path contains
58 "LayoutTests" directory, locates this directory, assuming it's either in
59 in webkit/data/layout_tests or in third_party/WebKit."""
60
61 if path != None and path.find('LayoutTests') == -1:
62 return LayoutDataDir()
63
64 global _layout_tests_dir
65 if _layout_tests_dir:
66 return _layout_tests_dir
67
68 if os.path.exists(os.path.join(LayoutDataDir(), 'LayoutTests')):
69 _layout_tests_dir = LayoutDataDir()
70 else:
71 _layout_tests_dir = google.path_utils.FindUpward(
72 google.path_utils.ScriptDir(), 'third_party', 'WebKit')
73
74 return _layout_tests_dir
75
54 def ChromiumPlatformResultsEnclosingDir(): 76 def ChromiumPlatformResultsEnclosingDir():
55 """Returns the full path to the directory containing Chromium platform 77 """Returns the full path to the directory containing Chromium platform
56 result directories. 78 result directories.
57 """ 79 """
58 # TODO(pamg): Once we move platform/chromium-* into LayoutTests/platform/, 80 # TODO(pamg): Once we move platform/chromium-* into LayoutTests/platform/,
59 # remove this and use PlatformResultsEnclosingDir() for everything. 81 # remove this and use PlatformResultsEnclosingDir() for everything.
60 return os.path.join(LayoutDataDir(), 'platform') 82 return os.path.join(LayoutDataDir(), 'platform')
61 83
62 def WebKitPlatformResultsEnclosingDir(): 84 def WebKitPlatformResultsEnclosingDir():
63 """Gets the full path to just above the platform results directory.""" 85 """Gets the full path to just above the platform results directory."""
64 return os.path.join(LayoutDataDir(), 'LayoutTests', 'platform') 86 return os.path.join(LayoutTestsDir(), 'LayoutTests', 'platform')
65 87
66 def PlatformResultsEnclosingDir(platform): 88 def PlatformResultsEnclosingDir(platform):
67 """Gets the path to just above the results directory for this platform.""" 89 """Gets the path to just above the results directory for this platform."""
68 if platform.startswith('chromium'): 90 if platform.startswith('chromium'):
69 return ChromiumPlatformResultsEnclosingDir() 91 return ChromiumPlatformResultsEnclosingDir()
70 return WebKitPlatformResultsEnclosingDir() 92 return WebKitPlatformResultsEnclosingDir()
71 93
72 def ExpectedFilename(filename, suffix, platform): 94 def ExpectedFilename(filename, suffix, platform):
73 """Given a test name, returns an absolute path to its expected results. 95 """Given a test name, returns an absolute path to its expected results.
74 96
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 platform_util = platform_utils.PlatformUtility('') 215 platform_util = platform_utils.PlatformUtility('')
194 # try output directory from either Xcode or chrome.sln 216 # try output directory from either Xcode or chrome.sln
195 full_path = platform_util.LayoutTestHelperBinaryPath(target) 217 full_path = platform_util.LayoutTestHelperBinaryPath(target)
196 if not os.path.exists(full_path): 218 if not os.path.exists(full_path):
197 raise PathNotFound('unable to find layout_test_helper at %s' % full_path) 219 raise PathNotFound('unable to find layout_test_helper at %s' % full_path)
198 return full_path 220 return full_path
199 221
200 def RelativeTestFilename(filename): 222 def RelativeTestFilename(filename):
201 """Provide the filename of the test relative to the layout data 223 """Provide the filename of the test relative to the layout data
202 directory as a unix style path (a/b/c).""" 224 directory as a unix style path (a/b/c)."""
203 return WinPathToUnix(filename[len(LayoutDataDir()) + 1:]) 225 return WinPathToUnix(filename[len(LayoutTestsDir(filename)) + 1:])
204 226
205 def GetPlatformUtil(): 227 def GetPlatformUtil():
206 """Returns a singleton instance of the PlatformUtility.""" 228 """Returns a singleton instance of the PlatformUtility."""
207 global _platform_util 229 global _platform_util
208 if not _platform_util: 230 if not _platform_util:
209 # Avoid circular import by delaying it. 231 # Avoid circular import by delaying it.
210 import layout_package.platform_utils 232 import layout_package.platform_utils
211 _platform_util = ( 233 _platform_util = (
212 layout_package.platform_utils.PlatformUtility(WebKitRoot())) 234 layout_package.platform_utils.PlatformUtility(WebKitRoot()))
213 return _platform_util 235 return _platform_util
214 236
215 # Map platform specific path utility functions. We do this as a convenience 237 # Map platform specific path utility functions. We do this as a convenience
216 # so importing path_utils will get all path related functions even if they are 238 # so importing path_utils will get all path related functions even if they are
217 # platform specific. 239 # platform specific.
218 def GetAbsolutePath(path): 240 def GetAbsolutePath(path):
219 return GetPlatformUtil().GetAbsolutePath(path) 241 return GetPlatformUtil().GetAbsolutePath(path)
220 242
221 def FilenameToUri(path): 243 def FilenameToUri(path):
222 return GetPlatformUtil().FilenameToUri(path) 244 return GetPlatformUtil().FilenameToUri(path)
223 245
224 def TestListPlatformDir(): 246 def TestListPlatformDir():
225 return GetPlatformUtil().TestListPlatformDir() 247 return GetPlatformUtil().TestListPlatformDir()
226 248
227 def PlatformDir(): 249 def PlatformDir():
228 return GetPlatformUtil().PlatformDir() 250 return GetPlatformUtil().PlatformDir()
229 251
230 def PlatformNewResultsDir(): 252 def PlatformNewResultsDir():
231 return GetPlatformUtil().PlatformNewResultsDir() 253 return GetPlatformUtil().PlatformNewResultsDir()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698