Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Track branch coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Jun 4, 2015
1 parent a325559 commit a0158cd
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
branch = true

[report]
exclude_lines =
<no-coverage>

# vim:ft=dosini
2 changes: 2 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax: glob

*.py[co]
.coverage
MANIFEST
build/
dist/
Expand Down
64 changes: 64 additions & 0 deletions private/update-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/python
# encoding=UTF-8

# Copyright © 2014-2015 Jakub Wilk <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

from __future__ import print_function

import glob
import io
import os
import sys

import nose
import nose.plugins.allmodules
import nose.plugins.cover

class Coverage(nose.plugins.cover.Coverage):

stream = None

def report(self, stream):
return super(Coverage, self).report(self.stream)


def main():
basedir = os.path.join(os.path.dirname(__file__), os.pardir)
os.chdir(basedir)
argv = [
sys.argv[0],
'--all-modules',
'--with-coverage',
'--cover-package=lib',
'--cover-erase',
'tests',
]
path = os.path.join('tests', 'coverage.txt')
plugin = Coverage()
report_stream = plugin.stream = io.BytesIO()
print('Generated automatically by private/update-coverage. '
'Do not edit.\n', file=report_stream)
plugins = [plugin, nose.plugins.allmodules.AllModules()]
ok = nose.run(argv=argv, plugins=plugins)
if not ok:
sys.exit(1)
report_stream.seek(0)
with open(path + '.tmp', 'w') as file:
for line in report_stream:
line = line.rstrip()
print(line, file=file)
os.rename(path + '.tmp', path)

if __name__ == '__main__':
main()

# vim:ts=4 sts=4 sw=4 et
30 changes: 30 additions & 0 deletions tests/coverage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Generated automatically by private/update-coverage. Do not edit.

Name Stmts Miss Branch BrMiss Cover Missing
-------------------------------------------------------------------
lib 5 2 4 2 56% 4, 6
lib.cli 7 3 0 0 57% 18-20
lib.cli.djvu2hocr 229 78 78 40 62% 64-65, 99, 101, 117, 121, 147-185, 188-211, 219-222, 237-240, 243-248, 253-258, 264, 334-335
lib.cli.hocr2djvused 41 1 8 1 96% 50
lib.cli.ocrodjvu 400 267 84 73 30% 52, 61, 64-69, 78, 81-82, 91, 94, 104-109, 118, 121-129, 132-160, 235, 253-258, 267-272, 276-335, 340-344, 347-351, 354-355, 359-366, 369-379, 382-404, 407-444, 447-520, 523-529, 532-535, 539-549
lib.engines 11 2 4 0 87% 23-24
lib.engines.common 36 14 8 5 57% 33-36, 44-48, 51, 54-56, 59
lib.engines.cuneiform 95 15 20 4 83% 49-50, 62-63, 86, 99-100, 104, 111, 116, 153-156, 162
lib.engines.gocr 124 78 46 44 28% 22-23, 42-51, 54-105, 126-127, 132, 137, 143, 146-149, 155-165, 168-171
lib.engines.ocrad 127 79 42 41 29% 34-43, 48-98, 114-115, 124-125, 137, 141-144, 148, 154-167, 170-173
lib.engines.ocropus 66 35 14 12 41% 44, 53-71, 75, 78, 81, 84-106, 109
lib.engines.tesseract 176 90 44 33 44% 51-65, 72-85, 93-94, 112-113, 122, 132-133, 138, 142, 153, 168-169, 176, 183-191, 194, 198, 201-210, 216-263, 269-273, 276-283
lib.errors 18 4 0 0 78% 17, 22, 37, 42
lib.hocr 289 32 188 31 87% 28-30, 121, 135, 153, 168, 188, 243, 248, 252, 277, 282, 284, 298, 301, 313, 326, 346, 352, 367, 378, 380, 393, 412, 433-440
lib.html5_support 8 3 0 0 63% 19-21
lib.image_io 98 7 18 3 91% 20-22, 41, 46, 49, 161
lib.ipc 71 8 28 10 82% 41-42, 46-47, 70-72, 103
lib.iso639 10 2 6 2 75% 52, 55
lib.logger 17 0 0 0 100%
lib.temporary 15 0 0 0 100%
lib.text_zones 143 15 54 8 88% 20, 28-30, 67, 90, 108, 110, 112, 114, 133, 136, 139, 154, 163
lib.unicode_support 29 8 8 0 78% 21-29
lib.utils 82 0 20 0 100%
lib.version 1 0 0 0 100%
-------------------------------------------------------------------
TOTAL 2098 743 674 309 62%
6 changes: 3 additions & 3 deletions tests/djvu2hocr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import sys
from cStringIO import StringIO

from ocrodjvu.cli import djvu2hocr
from ocrodjvu import temporary
from ocrodjvu import ipc
from lib.cli import djvu2hocr
from lib import temporary
from lib import ipc

from tests.common import (
assert_equal,
Expand Down
2 changes: 1 addition & 1 deletion tests/hocr2djvused/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
from cStringIO import StringIO

from ocrodjvu.cli import hocr2djvused
from lib.cli import hocr2djvused

from tests.common import (
assert_equal,
Expand Down
2 changes: 1 addition & 1 deletion tests/image_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import djvu.decode

from ocrodjvu import image_io
from lib import image_io

from tests.common import (
assert_equal,
Expand Down
2 changes: 1 addition & 1 deletion tests/ocrodjvu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
from cStringIO import StringIO

from ocrodjvu.cli import ocrodjvu
from lib.cli import ocrodjvu

from tests.common import (
assert_equal,
Expand Down

0 comments on commit a0158cd

Please sign in to comment.