Skip to content

Commit

Permalink
coverage: Bring up to date with the latest Ren'Py.
Browse files Browse the repository at this point in the history
  • Loading branch information
renpytom committed Oct 15, 2016
1 parent 192bda6 commit 963bf51
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions renpycoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import Cython.Coverage
import os
import coverage # @UnresolvedImport
import coverage # @UnresolvedImport
import cPickle
import ast

ROOT = os.path.dirname(os.path.abspath(__file__))


def _find_c_source(base_path):

base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "module", "gen.coverage", os.path.basename(base_path))
Expand All @@ -27,12 +28,12 @@ def _find_c_source(base_path):
class FixedCythonReporter(coverage.FileReporter):

def __init__(self, old, fn):
# fn = old.filename
#
# if not os.path.exists(fn):
# new_fn = os.path.join(os.path.dirname(fn), "module", os.path.basename(fn))
# if os.path.exists(new_fn):
# fn = new_fn
# fn = old.filename
#
# if not os.path.exists(fn):
# new_fn = os.path.join(os.path.dirname(fn), "module", os.path.basename(fn))
# if os.path.exists(new_fn):
# fn = new_fn

super(FixedCythonReporter, self).__init__(fn)

Expand Down Expand Up @@ -63,6 +64,7 @@ def _find_source_files(self, filename):
"renpy/gl",
"renpy/styledata",
"renpy/text",
"renpy/audio",
]

for i in pyx_search:
Expand All @@ -71,10 +73,8 @@ def _find_source_files(self, filename):
if os.path.exists(pyx_fn):
break
else:
print("Could not find pyx for", filename)
return None, None


c_base = os.path.basename(filename)[:-4] + ".c"

modules = [
Expand All @@ -84,6 +84,7 @@ def _find_source_files(self, filename):
"renpy.gl.",
"renpy.styledata.",
"renpy.text.",
"renpy.audio.",
"pysdlsound."
]

Expand All @@ -97,7 +98,6 @@ def _find_source_files(self, filename):

return c_fn, pyx_fn


def file_tracer(self, filename):

if not filename.endswith(".pyx"):
Expand Down Expand Up @@ -135,6 +135,7 @@ def source_filename(self):


class PycodeVisitor(ast.NodeVisitor):

def __init__(self, lines):
self.lines = lines

Expand Down Expand Up @@ -238,6 +239,7 @@ def pycode_lines(self, pycode):
def lines(self):
return self._lines


class RenpyCoverage(coverage.CoveragePlugin):

def file_tracer(self, filename):
Expand Down

0 comments on commit 963bf51

Please sign in to comment.