Reviewers: ulan,
Message:
PTAL
Description:
Add coverage analysis to push and merge script tests.
The coverage analysis must live in an extra file in order to analyze the
scripts
when being imported.
TEST=tools/push-to-trunk/script_test.py
Please review this at https://codereview.chromium.org/183923013/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+27, -14 lines):
A + tools/push-to-trunk/script_test.py
M tools/push-to-trunk/test_scripts.py
Index: tools/push-to-trunk/script_test.py
diff --git a/build/gyp_v8.py b/tools/push-to-trunk/script_test.py
old mode 100644
new mode 100755
similarity index 66%
copy from build/gyp_v8.py
copy to tools/push-to-trunk/script_test.py
index
462ee674acbbc5880fe685507fb4527976f50de2..cbb2134f6d92f9d7a8c8e7dda3a3a2e9e1c0a45c
--- a/build/gyp_v8.py
+++ b/tools/push-to-trunk/script_test.py
@@ -1,4 +1,5 @@
-# Copyright 2013 the V8 project authors. All rights reserved.
+#!/usr/bin/env python
+# Copyright 2014 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -25,17 +26,29 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# This file is (possibly, depending on python version) imported by
-# gyp_v8 when GYP_PARALLEL=1 and it creates sub-processes through the
-# multiprocessing library.
-
-# Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for
imports
-# that don't end in .py (and aren't directories with an __init__.py). This
-# wrapper makes "import gyp_v8" work with those old versions and makes it
-# possible to execute gyp_v8.py directly on Windows where the extension is
-# useful.
+# Wraps test execution with a coverage analysis. To get the best speed, the
+# native python coverage version >= 3.7.1 should be installed.
+import coverage
import os
+import unittest
+import sys
+
+
+def Main(argv):
+ script_path = os.path.dirname(os.path.abspath(__file__))
+ cov = coverage.coverage(include=([os.path.join(script_path, '*.py')]))
+ cov.start()
+ import test_scripts
+ alltests = map(unittest.TestLoader().loadTestsFromTestCase, [
+ test_scripts.ToplevelTest,
+ test_scripts.ScriptTest,
+ test_scripts.SystemTest,
+ ])
+ unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(alltests))
+ cov.stop()
+ print cov.report()
+
-path = os.path.abspath(os.path.split(__file__)[0])
-execfile(os.path.join(path, 'gyp_v8'))
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
Index: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py
b/tools/push-to-trunk/test_scripts.py
index
657a086a1a656729b045a52820dd0fa3fd7d4aed..711023fffc1e146d4d9e71889a83735cb1b4b872
100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -238,7 +238,7 @@ class SimpleMock(object):
def Expect(self, recipe):
self._recipe = recipe
- def Call(self, *args):
+ def Call(self, *args): # pragma: no cover
self._index += 1
try:
expected_call = self._recipe[self._index]
@@ -276,7 +276,7 @@ class SimpleMock(object):
raise return_value
return return_value
- def AssertFinished(self):
+ def AssertFinished(self): # pragma: no cover
if self._index < len(self._recipe) -1:
raise NoRetryException("Called %s too seldom: %d vs. %d"
% (self._name, self._index,
len(self._recipe)))
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.