| OLD | NEW |
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 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 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 def webkit_base(self): | 44 def webkit_base(self): |
| 45 """Returns the absolute path to the top of the WebKit tree. | 45 """Returns the absolute path to the top of the WebKit tree. |
| 46 | 46 |
| 47 Raises an AssertionError if the top dir can't be determined.""" | 47 Raises an AssertionError if the top dir can't be determined.""" |
| 48 # Note: This code somewhat duplicates the code in | 48 # Note: This code somewhat duplicates the code in |
| 49 # scm.find_checkout_root(). However, that code only works if the top | 49 # scm.find_checkout_root(). However, that code only works if the top |
| 50 # of the SCM repository also matches the top of the WebKit tree. Some SV
N users | 50 # of the SCM repository also matches the top of the WebKit tree. Some SV
N users |
| 51 # (the chromium test bots, for example), might only check out subdirecto
ries like | 51 # (the chromium test bots, for example), might only check out subdirecto
ries like |
| 52 # Tools/Scripts. This code will also work if there is no SCM system at a
ll. | 52 # Tools/Scripts. This code will also work if there is no SCM system at a
ll. |
| 53 # TODO(qyearsley): Remove duplicate code; we're not concerned with SVN u
sers anymore. |
| 54 # Also, instead of caching the result with a private instance variable,
we can use |
| 55 # the memoized decorator. |
| 53 if not self._webkit_base: | 56 if not self._webkit_base: |
| 54 self._webkit_base = self._webkit_base | 57 self._webkit_base = self._webkit_base |
| 55 module_path = self._filesystem.abspath(self._filesystem.path_to_modu
le(self.__module__)) | 58 module_path = self._filesystem.abspath(self._filesystem.path_to_modu
le(self.__module__)) |
| 56 tools_index = module_path.rfind('Tools') | 59 tools_index = module_path.rfind('Tools') |
| 57 assert tools_index != -1, "could not find location of this checkout
from %s" % module_path | 60 assert tools_index != -1, "could not find location of this checkout
from %s" % module_path |
| 58 self._webkit_base = self._filesystem.normpath(module_path[0:tools_in
dex - 1]) | 61 self._webkit_base = self._filesystem.normpath(module_path[0:tools_in
dex - 1]) |
| 59 return self._webkit_base | 62 return self._webkit_base |
| 60 | 63 |
| 61 def chromium_base(self): | 64 def chromium_base(self): |
| 62 if not self._chromium_base: | 65 if not self._chromium_base: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 # This is intentionally relative in order to force callers to consider w
hat | 77 # This is intentionally relative in order to force callers to consider w
hat |
| 75 # their current working directory is (and change to the top of the tree
if necessary). | 78 # their current working directory is (and change to the top of the tree
if necessary). |
| 76 return self._filesystem.join("Tools", "Scripts", script_name) | 79 return self._filesystem.join("Tools", "Scripts", script_name) |
| 77 | 80 |
| 78 def layout_tests_dir(self): | 81 def layout_tests_dir(self): |
| 79 return self.path_from_webkit_base('LayoutTests') | 82 return self.path_from_webkit_base('LayoutTests') |
| 80 | 83 |
| 81 def perf_tests_dir(self): | 84 def perf_tests_dir(self): |
| 82 return self.path_from_webkit_base('PerformanceTests') | 85 return self.path_from_webkit_base('PerformanceTests') |
| 83 | 86 |
| 87 def layout_test_name(self, file_path): |
| 88 """Returns a layout test name, given the path from the repo root. |
| 89 |
| 90 Args: |
| 91 file_path: A relative path from the root of the Chromium repo. |
| 92 |
| 93 Returns: |
| 94 The normalized layout test name, which is just the relative path fro
m |
| 95 the LayoutTests directory, using forward slash as the path separator
. |
| 96 Returns None if the given file is not in the LayoutTests directory. |
| 97 """ |
| 98 layout_tests_abs_path = self._filesystem.join(self.webkit_base(), self.l
ayout_tests_dir()) |
| 99 layout_tests_rel_path = self._filesystem.relpath(layout_tests_abs_path,
self.chromium_base()) |
| 100 if not file_path.startswith(layout_tests_rel_path): |
| 101 return None |
| 102 return file_path[len(layout_tests_rel_path) + 1:] |
| 103 |
| 84 def depot_tools_base(self): | 104 def depot_tools_base(self): |
| 85 if not self._depot_tools: | 105 if not self._depot_tools: |
| 86 # This basically duplicates src/build/find_depot_tools.py without th
e side effects | 106 # This basically duplicates src/build/find_depot_tools.py without th
e side effects |
| 87 # (adding the directory to sys.path and importing breakpad). | 107 # (adding the directory to sys.path and importing breakpad). |
| 88 self._depot_tools = (self._check_paths_for_depot_tools(self._sys_pat
h) or | 108 self._depot_tools = (self._check_paths_for_depot_tools(self._sys_pat
h) or |
| 89 self._check_paths_for_depot_tools(self._env_pat
h) or | 109 self._check_paths_for_depot_tools(self._env_pat
h) or |
| 90 self._check_upward_for_depot_tools()) | 110 self._check_upward_for_depot_tools()) |
| 91 return self._depot_tools | 111 return self._depot_tools |
| 92 | 112 |
| 93 def _check_paths_for_depot_tools(self, paths): | 113 def _check_paths_for_depot_tools(self, paths): |
| 94 for path in paths: | 114 for path in paths: |
| 95 if path.rstrip(self._dirsep).endswith('depot_tools'): | 115 if path.rstrip(self._dirsep).endswith('depot_tools'): |
| 96 return path | 116 return path |
| 97 return None | 117 return None |
| 98 | 118 |
| 99 def _check_upward_for_depot_tools(self): | 119 def _check_upward_for_depot_tools(self): |
| 100 fs = self._filesystem | 120 fs = self._filesystem |
| 101 prev_dir = '' | 121 prev_dir = '' |
| 102 current_dir = fs.dirname(self._webkit_base) | 122 current_dir = fs.dirname(self._webkit_base) |
| 103 while current_dir != prev_dir: | 123 while current_dir != prev_dir: |
| 104 if fs.exists(fs.join(current_dir, 'depot_tools', 'pylint.py')): | 124 if fs.exists(fs.join(current_dir, 'depot_tools', 'pylint.py')): |
| 105 return fs.join(current_dir, 'depot_tools') | 125 return fs.join(current_dir, 'depot_tools') |
| 106 prev_dir = current_dir | 126 prev_dir = current_dir |
| 107 current_dir = fs.dirname(current_dir) | 127 current_dir = fs.dirname(current_dir) |
| 108 | 128 |
| 109 def path_from_depot_tools_base(self, *comps): | 129 def path_from_depot_tools_base(self, *comps): |
| 110 return self._filesystem.join(self.depot_tools_base(), *comps) | 130 return self._filesystem.join(self.depot_tools_base(), *comps) |
| OLD | NEW |