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

Unified Diff: scripts/slave/unittests/expect_tests/type_definitions.py

Issue 354913003: Add module discovery and autoloading to expect_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: add --force_coverage option Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: scripts/slave/unittests/expect_tests/type_definitions.py
diff --git a/scripts/slave/unittests/expect_tests/type_definitions.py b/scripts/slave/unittests/expect_tests/type_definitions.py
index b95843e69c1ac068fa19013b6a6866bc895b1a91..dda7ed3b168c282b7a7b8a24f173d95c4f57ca0b 100644
--- a/scripts/slave/unittests/expect_tests/type_definitions.py
+++ b/scripts/slave/unittests/expect_tests/type_definitions.py
@@ -18,6 +18,7 @@ UnknownError = namedtuple('UnknownError', 'message')
NoMatchingTestsError = namedtuple('NoMatchingTestsError', '')
Result = namedtuple('Result', 'data')
MultiResult = namedtuple('MultiResult', 'results')
+Cleanup = namedtuple('Cleanup', 'func_call')
class ResultStageAbort(Exception):
pass
@@ -191,11 +192,10 @@ class Test(_Test):
return super(Test, cls).__new__(cls, name, func_call, expect_dir,
expect_base, ext, covers, breakpoints)
- def coverage_includes(self):
- if self.covers is not None:
- return self.covers
- test_file = inspect.getabsfile(self.func_call.func)
+ @staticmethod
+ def covers_obj(obj):
+ test_file = inspect.getabsfile(obj)
covers = [test_file]
match = Test.TEST_COVERS_MATCH.match(test_file)
if match:
@@ -203,18 +203,26 @@ class Test(_Test):
os.path.dirname(os.path.dirname(test_file)),
match.group(1) + '.py'
))
-
return covers
+ @staticmethod
+ def expect_dir_obj(obj):
+ test_file = inspect.getabsfile(obj)
+ # trim off the '.py'
+ return test_file[:-3] + '.expected'
+
+ def coverage_includes(self):
+ if self.covers is not None:
+ return self.covers
+ return self.covers_obj(self.func_call.func)
+
def expect_path(self, ext=None):
expect_dir = self.expect_dir
if expect_dir is None:
- # trim off the '.py'
- test_file = inspect.getabsfile(self.func_call.func)
- expect_dir = test_file[:-3] + '.expected'
+ expect_dir = self.expect_dir_obj(self.func_call.func)
name = self.expect_base or self.name
name = ''.join('_' if c in '<>:"\\/|?*\0' else c for c in name)
- return os.path.join(self.expect_dir, name + ('.%s' % (ext or self.ext)))
+ return os.path.join(expect_dir, name + ('.%s' % (ext or self.ext)))
def run(self, context=None):
return self.func_call(context=context)

Powered by Google App Engine
This is Rietveld 408576698