Commit 2998b840 authored by Kirill Smelkov's avatar Kirill Smelkov

Merge branch 'master' into t

* master:
  coverage: CacheItem.__repr__ (client)
  New neotestrunner option for code coverage testing
parents 8c736e77 46491261
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
*.pyo *.pyo
*.swp *.swp
*~ *~
/.coverage
/build/ /build/
/dist/ /dist/
/htmlcov/
/mock.py /mock.py
/neoppod.egg-info/ /neoppod.egg-info/
In order to check the test-coverage of Neo, we used the figleaf tool. The usage
(for a complete neo test suite) is :
Download and install figleaf : http://darcs.idyll.org/~t/projects/figleaf/doc/
$ figleaf neotestrunner -u (it will generate a .figleaf file)
$figleaf2html .figleaf (to convert .figleaf file in html pages)
$firefox html/ (to read the results)
Each one of the page contains Neo code, which the following colours :
Green : Executed code during test suite
Red : Unexecuted code
Black : Comments and "unused" lines
In order to check only needed neo file, you should specify the following options:
figleaf -i : ignore python libraries
figleaf2html -f : allows to specify a list of check-needed files
For stats, you can also check the index.html page, which indicated which
percentage of test-coverage.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
General General
- Review XXX/TODO code tags (CODE) - Review XXX/TODO code tags (CODE)
- Coverage for functional tests (i.e. collect results from subprocesses)
- When all cells are OUT_OF_DATE in backup mode, the one with most data - When all cells are OUT_OF_DATE in backup mode, the one with most data
could become UP_TO_DATE with appropriate backup_tid, so that the cluster could become UP_TO_DATE with appropriate backup_tid, so that the cluster
stays operational. (FEATURE) stays operational. (FEATURE)
......
...@@ -307,6 +307,7 @@ def test(self): ...@@ -307,6 +307,7 @@ def test(self):
self.assertEqual([5, 10, 15, 20], [x.tid for x in cache._oid_dict[1]]) self.assertEqual([5, 10, 15, 20], [x.tid for x in cache._oid_dict[1]])
self.assertRaises(AssertionError, cache.store, 1, '20', 20, None) self.assertRaises(AssertionError, cache.store, 1, '20', 20, None)
repr(cache) repr(cache)
map(repr, cache._queue_list)
# Test late invalidations. # Test late invalidations.
cache.clear() cache.clear()
cache.store(1, '10*', 10, None) cache.store(1, '10*', 10, None)
......
...@@ -20,11 +20,23 @@ import unittest ...@@ -20,11 +20,23 @@ import unittest
import logging import logging
import time import time
import sys import sys
import neo
import os import os
import re
from collections import Counter, defaultdict from collections import Counter, defaultdict
from cStringIO import StringIO from cStringIO import StringIO
from unittest.runner import _WritelnDecorator from unittest.runner import _WritelnDecorator
if filter(re.compile(r'--coverage$|-\w*c').match, sys.argv[1:]):
# Start coverage as soon as possible.
import coverage
coverage = coverage.Coverage(source=('neo',), omit=(
'neo/debug.py',
'neo/scripts/runner.py',
'neo/tests/*',
))
coverage.start()
import neo
from neo.tests import getTempDirectory, __dict__ as neo_tests__dict__ from neo.tests import getTempDirectory, __dict__ as neo_tests__dict__
from neo.tests.benchmark import BenchmarkRunner from neo.tests.benchmark import BenchmarkRunner
...@@ -203,6 +215,8 @@ class NeoTestRunner(unittest.TextTestResult): ...@@ -203,6 +215,8 @@ class NeoTestRunner(unittest.TextTestResult):
class TestRunner(BenchmarkRunner): class TestRunner(BenchmarkRunner):
def add_options(self, parser): def add_options(self, parser):
parser.add_option('-c', '--coverage', action='store_true',
help='Enable coverage (not working yet for functional tests)')
parser.add_option('-f', '--functional', action='store_true', parser.add_option('-f', '--functional', action='store_true',
help='Functional tests') help='Functional tests')
parser.add_option('-u', '--unit', action='store_true', parser.add_option('-u', '--unit', action='store_true',
...@@ -240,6 +254,7 @@ Environment Variables: ...@@ -240,6 +254,7 @@ Environment Variables:
functional = options.functional, functional = options.functional,
zodb = options.zodb, zodb = options.zodb,
verbosity = 2 if options.verbose else 1, verbosity = 2 if options.verbose else 1,
coverage = options.coverage,
) )
def start(self): def start(self):
...@@ -256,6 +271,9 @@ Environment Variables: ...@@ -256,6 +271,9 @@ Environment Variables:
except KeyboardInterrupt: except KeyboardInterrupt:
config['mail_to'] = None config['mail_to'] = None
traceback.print_exc() traceback.print_exc()
if config.coverage:
coverage.stop()
coverage.save()
# build report # build report
self._successful = runner.wasSuccessful() self._successful = runner.wasSuccessful()
return runner.buildReport(self.add_status) return runner.buildReport(self.add_status)
......
...@@ -38,7 +38,7 @@ extras_require = { ...@@ -38,7 +38,7 @@ extras_require = {
'storage-mysqldb': ['mysqlclient'], 'storage-mysqldb': ['mysqlclient'],
'storage-importer': zodb_require, 'storage-importer': zodb_require,
} }
extras_require['tests'] = ['zope.testing', 'psutil>=2', extras_require['tests'] = ['coverage', 'zope.testing', 'psutil>=2',
'neoppod[%s]' % ', '.join(extras_require)] 'neoppod[%s]' % ', '.join(extras_require)]
try: try:
......
#!/bin/sh -e
for COV in coverage python-coverage
do type $COV && break
done >/dev/null 2>&1 || exit
$COV html
# https://bitbucket.org/ned/coveragepy/issues/474/javascript-in-html-captures-all-keys
sed -i "
/assign_shortkeys *=/s/$/return;/
/^ *\.bind('keydown',/s,^,//,
" htmlcov/coverage_html.js
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment