Home | History | Annotate | Download | only in test_defs

Lines Matching refs:path

34   def FindTests(self, path):
35 """Gets list of Android tests found at given path.
38 files relative to the given path.
45 FindTests will first scan sub-folders of path for tests. If none are found,
49 Some sample values for path:
65 path: file system path to search
71 if not os.path.exists(path):
72 logger.Log('%s does not exist' % path)
74 realpath = os.path.realpath(path)
75 # ensure path is in ANDROID_BUILD_ROOT
76 self._build_top = os.path.realpath(android_build.GetTop())
79 (path, self._build_top))
82 # first, assume path is a parent directory, which specifies to run all
86 logger.SilentLog('No tests found within %s, searching upwards' % path)
90 def _IsPathInBuildTree(self, path):
91 """Return true if given path is within current Android build tree.
94 path: absolute file system path
97 True if path is within Android build tree
99 return os.path.commonprefix([self._build_top, path]) == self._build_top
101 def _MakePathRelativeToBuild(self, path):
102 """Convert given path to one relative to build tree root.
105 path: absolute file system path to convert.
108 The converted path relative to build tree root.
111 ValueError: if path is not within build tree
113 if not self._IsPathInBuildTree(path):
117 return path[build_path_len:]
119 def _FindSubTests(self, path, tests, upstream_build_path=None):
120 """Recursively finds all tests within given path.
123 path: absolute file system path to check
131 if not os.path.isdir(path):
133 android_mk_parser = android_mk.CreateAndroidMK(path)
135 build_rel_path = self._MakePathRelativeToBuild(path)
138 # dir as build path
140 android_mk_parser, path, build_rel_path))
142 tests.extend(self._CreateSuites(android_mk_parser, path,
147 # Try to build as much of original path as possible, so
155 # found rule to build sub-directories. The parent path can be used,
156 # or if not set, use current path
158 upstream_build_path = self._MakePathRelativeToBuild(path)
161 for filename in os.listdir(path):
162 self._FindSubTests(os.path.join(path, filename), tests,
166 def _FindUpstreamTests(self, path):
167 """Find tests defined upward from given path.
170 path: the location to start searching.
175 factory = self._FindUpstreamTestFactory(path)
177 return factory.CreateTests(sub_tests_path=path)
181 def _GetTestFactory(self, android_mk_parser, path, build_path):
184 If given path is a valid tests build path, will return the TestFactory
189 path: the filesystem path of the makefile
190 build_path: filesystem path for the directory
194 the TestFactory or None if path is not a valid tests build path
197 return gtest.GTestFactory(path, build_path)
198 elif instrumentation_test.HasInstrumentationTest(path):
199 return instrumentation_test.InstrumentationTestFactory(path,
204 % path)
208 def _GetTestFactoryForPath(self, path):
209 """Get the test factory for given path.
211 If given path is a valid tests build path, will return the TestFactory
215 path: the filesystem path to evaluate
218 the TestFactory or None if path is not a valid tests build path
220 android_mk_parser = android_mk.CreateAndroidMK(path)
222 build_path = self._MakePathRelativeToBuild(path)
223 return self._GetTestFactory(android_mk_parser, path, build_path)
227 def _FindUpstreamTestFactory(self, path):
231 path: file system path to search
236 factory = self._GetTestFactoryForPath(path)
239 dirpath = os.path.dirname(path)
240 if self._IsPathInBuildTree(path):
245 def _CreateSuites(self, android_mk_parser, path, upstream_build_path):
250 path: absolute file system path of the makefile to evaluate
251 upstream_build_path: the build path to use for test. This can be
252 different than the 'path', in cases where an upstream makefile
258 factory = self._GetTestFactory(android_mk_parser, path,
261 return factory.CreateTests(path)