Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: 
Changeset: r94335:5c8076e87315
Date: 2018-04-15 15:32 +0100
http://bitbucket.org/pypy/pypy/changeset/5c8076e87315/

Log:    Delete obsolete code

diff --git a/pypy/tool/pytest/genreportdata.py 
b/pypy/tool/pytest/genreportdata.py
deleted file mode 100755
--- a/pypy/tool/pytest/genreportdata.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env python
-import py
-import sys
-        
-mydir = py.path.local(__file__).dirpath().realpath()
-from pypy.tool.pytest import htmlreport 
-from pypy.tool.pytest import confpath 
-
-if __name__ == '__main__':
-    if len(sys.argv) > 1:
-        testresultdir = py.path.local(sys.argv[1])
-        assert testresultdir.check(dir=1)        
-    else:
-        testresultdir = confpath.testresultdir 
-        assert testresultdir.check(dir=1)
-        try:
-            resultwc = py.path.svnwc(testresultdir)
-            print "updating", resultwc
-            resultwc.update()
-        except (KeyboardInterrupt, RuntimeError):
-            raise
-        except Exception as e: #py.process.ExecutionFailed,e:
-            print >> sys.stderr, "Warning: ",e #Subversion update failed"
-
-    print "traversing", mydir 
-    rep = htmlreport.HtmlReport(testresultdir)
-    rep.parselatest()
-
-    print "making html files"
-    rep.makeindex(testresultdir.join('index.html'))
diff --git a/pypy/tool/pytest/htmlreport.py b/pypy/tool/pytest/htmlreport.py
deleted file mode 100644
--- a/pypy/tool/pytest/htmlreport.py
+++ /dev/null
@@ -1,239 +0,0 @@
-#! /usr/bin/env python
-
-"""
-the html test reporter 
-
-"""
-import sys, os, re
-import pprint
-import py 
-from pypy.tool.pytest import result
-from pypy.tool.pytest.overview import ResultCache 
-
-# 
-# various interesting path objects 
-#
-
-html = py.xml.html
-NBSP = py.xml.raw("&nbsp;")
-
-class HtmlReport(object): 
-    def __init__(self, resultdir): 
-        self.resultcache = ResultCache(resultdir)
-
-    def parselatest(self): 
-        self.resultcache.parselatest()
-
-    # 
-    # rendering 
-    # 
-
-    def render_latest_table(self, results): 
-        table = html.table(
-                    [html.th(x, align='left') 
-                        for x in ("failure", "filename", "revision", 
-                                  "user", "platform", "elapsed", 
-                                  "options", "last error line"
-                                  )], 
-                )
-        r = results[:]
-        def f(x, y): 
-            xnum = x.isok() and 1 or (x.istimeout() and 2 or 3)
-            ynum = y.isok() and 1 or (y.istimeout() and 2 or 3)
-            res = -cmp(xnum, ynum)
-            if res == 0: 
-                return cmp(x['execution-time'], y['execution-time'])
-            return res 
-        r.sort(f) 
-        for result in r: 
-            table.append(self.render_result_row(result))
-        return table 
-
-    def render_result_row(self, result): 
-        dp = py.path.local(result['fspath']) 
-
-        options = " ".join([x for x in result.get('options', []) if x!= 
'core'])
-        if not options: 
-            options = NBSP
-
-        failureratio = 100 * (1.0 - result.ratio_of_passed())
-        self.data[result.testname] = failureratio
-        return html.tr(
-                html.td("%.2f%%" % failureratio, 
-                    style = "background-color: %s" % 
(getresultcolor(result),)), 
-                html.td(self.render_test_references(result)),
-                html.td(result['pypy-revision']),
-                html.td(result['userhost'][:15]), 
-                html.td(result['platform']), 
-                html.td("%.2fs" % result['execution-time']),
-                html.td(options), 
-                html.td(result.repr_short_error() or NBSP)
-        )
-
-    def getrelpath(self, p): 
-        return p.relto(self.indexpath.dirpath())
-
-    def render_test_references(self, result): 
-        dest = self.make_single_test_result(result)
-        #XXX: ask hg for differences between test and vendor branch
-        modified = result.ismodifiedtest() and " [mod]" or ""
-        return html.div(html.a(result.path.purebasename + modified, 
-                      href=self.getrelpath(dest)),
-                      style="background-color: transparent")
-
-    def make_single_test_result(self, result): 
-        cache = self.indexpath.dirpath('.cache', result['userhost'][:15])
-        cache.ensure(dir=1)
-        dest = cache.join(result.path.basename).new(ext='.html')
-        doc = ViewResult(result)
-        doc.writetopath(dest)
-        return dest
-
-    def getcorelists(self): 
-        def iscore(result): 
-            return 'core' in result.get('options', []) 
-        coretests = []
-        noncoretests = []
-        for name in self.resultcache.getnames(): 
-            result = self.resultcache.getlatestrelevant(name)
-            if iscore(result): 
-                coretests.append(result)
-            else: 
-                noncoretests.append(result) 
-        return coretests, noncoretests 
-    
-    # generate html files 
-    #
-    def makeindex(self, indexpath, detail="PyPy - latest"): 
-        self.indexpath = indexpath
-        self.data = {}
-        doc = Document(title='pypy test results')
-        body = doc.body
-        coretests, noncoretests = self.getcorelists()
-        body.append(html.h2("%s compliance test results - "
-                            "core tests" % detail))
-
-        body.append(self.render_test_summary('core', coretests))
-        body.append(self.render_latest_table(coretests))
-        body.append(
-            html.h2("%s compliance test results - non-core tests" % detail))
-        body.append(self.render_test_summary('noncore', noncoretests))
-        body.append(self.render_latest_table(noncoretests))
-        doc.writetopath(indexpath)
-        datapath = indexpath.dirpath().join('data')
-        d = datapath.open('w')
-        print >>d, "data = ",
-        pprint.pprint(self.data, stream=d)
-        d.close()
-        self.data = None
-        
-    def render_test_summary(self, tag, tests):
-        ok = len([x for x in tests if x.isok()])
-        err = len([x for x in tests if x.iserror()])
-        to = len([x for x in tests if x.istimeout()])
-        numtests = ok + err + to
-        assert numtests == len(tests)
-        assert numtests
-
-        t = html.table()
-        sum100 = numtests / 100.0
-        def row(*args):
-            return html.tr(*[html.td(arg) for arg in args])
-
-        sum_passed = sum([x.ratio_of_passed() for x in tests])
-        compliancy = sum_passed/sum100
-        self.data['%s-compliancy' % tag] = compliancy 
-        t.append(row(html.b("tests compliancy"), 
-                     html.b("%.2f%%" % (compliancy,))))
-
-        passed = ok/sum100
-        self.data['%s-passed' % tag] = passed
-        t.append(row("testmodules passed completely", "%.2f%%" % passed))
-        failed = err/sum100
-        self.data['%s-failed' % tag] = failed
-        t.append(row("testmodules (partially) failed", "%.2f%%" % failed))
-        timedout = to/sum100
-        self.data['%s-timedout' % tag] = timedout
-        t.append(row("testmodules timeout", "%.2f%%" % timedout))
-        return t
-
-class Document(object): 
-    def __init__(self, title=None): 
-        self.body = html.body()
-        self.head = html.head()
-        self.doc = html.html(self.head, self.body)
-        if title is not None: 
-            self.head.append(
-                html.meta(name="title", content=title))
-        self.head.append(
-            html.link(rel="Stylesheet", type="text/css", 
href="/pypy/default.css"))
-
-    def writetopath(self, p): 
-        assert p.ext == '.html'
-        self.head.append(
-            html.meta(name="Content-Type", content="text/html;charset=UTF-8")
-        )
-        s = self.doc.unicode().encode('utf-8')
-        p.write(s) 
-       
-def getresultcolor(result): 
-    if result.isok(): 
-        color = "#00ee00"
-    elif result.iserror(): 
-        color = "#ee0000" 
-    elif result.istimeout: 
-        color = "#0000ee"
-    else: 
-        color = "#444444"
-    return color 
-
-class ViewResult(Document): 
-    def __init__(self, result): 
-        title = "%s testresult" % (result.path.purebasename,)
-        super(ViewResult, self).__init__(title=title)
-        color = getresultcolor(result)
-        self.body.append(html.h2(title, 
-                    style="background-color: %s" % color))
-        self.body.append(self.render_meta_info(result))
-
-        for name in ('reportdiff', 'stdout', 'stderr'): 
-            try: 
-                text = result.getnamedtext(name)
-            except KeyError: 
-                continue
-            self.body.append(html.h3(name))
-            self.body.append(html.pre(text))
-
-    def render_meta_info(self, result):
-        t = html.table()
-        items = result.items()
-        items.sort()
-        for name, value in items: 
-            if name.lower() == name:
-                t.append(html.tr(
-                    html.td(name), html.td(value)))
-        return t 
- 
-class TestOfHtmlReportClass: 
-    def setup_class(cls): 
-        py.test.skip('needs move to own test file')
-        cls.testresultdir = confpath.testresultdir 
-        cls.rep = rep = HtmlReport()
-        rep.parse_all(cls.testresultdir)
-
-    def test_pickling(self): 
-        # test pickling of report 
-        tempdir = py.test.ensuretemp('reportpickle')
-        picklepath = tempdir.join('report.pickle')
-        picklepath.dump(self.rep)
-        x = picklepath.load()
-        assert len(x.results) == len(self.rep.results)
-    
-    def test_render_latest(self): 
-        t = self.rep.render_latest_table(self.rep.results)
-        assert unicode(t)
-
-mydir = py.path.local(__file__).dirpath()
-
-def getpicklepath(): 
-    return mydir.join('.htmlreport.pickle')
diff --git a/pypy/tool/pytest/overview.py b/pypy/tool/pytest/overview.py
deleted file mode 100644
--- a/pypy/tool/pytest/overview.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from pypy.tool.pytest import result 
-import sys
-
-class ResultCache: 
-    def __init__(self, resultdir):
-        self.resultdir = resultdir
-        self.name2result = {}
-
-    def parselatest(self): 
-        def filefilter(p): 
-            return p.check(fnmatch='test_*.txt', file=1)
-        def rec(p): 
-            return p.check(dotfile=0)
-        for x in self.resultdir.visit(filefilter, rec): 
-            self.parse_one(x)
-    
-    def parse_one(self, resultpath):
-        try: 
-            res = result.ResultFromMime(resultpath) 
-            ver = res['testreport-version']
-            if ver != "1.1" and ver != "1.1.1":
-                raise TypeError
-        except TypeError: # xxx
-            print >>sys.stderr, "could not parse %s" % resultpath
-            return
-        name = res.testname 
-        print name
-        self.name2result.setdefault(name, []).append(res) 
-        return res 
-
-    def getnames(self): 
-        return self.name2result.keys()
-
-    def getlatest(self, name, timeout=0, error=0, ok=0): 
-        l = []
-        resultlist = self.name2result[name]
-        maxrev = 0
-        maxresult = None
-        for res in resultlist:
-            resrev = res['pypy-revision']
-            if resrev == 'unknown': 
-                continue 
-            if resrev <= maxrev: 
-                continue 
-            if timeout or error or ok:
-                if not (timeout and res.istimeout() or
-                        error and res.iserror() or 
-                        ok and res.isok()): 
-                    continue 
-            maxrev = resrev 
-            maxresult = res 
-        return maxresult 
-
-    def getlatestrelevant(self, name):
-        # get the latest revision that did not time out.
-        return self.getlatest(name, error=1, ok=1) or self.getlatest(name)
diff --git a/pypy/tool/pytest/result.py b/pypy/tool/pytest/result.py
deleted file mode 100644
--- a/pypy/tool/pytest/result.py
+++ /dev/null
@@ -1,215 +0,0 @@
-import sys
-import py
-import re
-
-class Result(object):
-    def __init__(self, init=True):
-        self._headers = {}
-        self._blocks = {}
-        self._blocknames = []
-        if init:
-            stdinit(self)
-
-    def __setitem__(self, name, value):
-        self._headers[name.lower()] = value
-
-    def __getitem__(self, name):
-        return self._headers[name.lower()]
-
-    def get(self, name, default):
-        return self._headers.get(name, default)
-
-    def __delitem__(self, name):
-        del self._headers[name.lower()]
-
-    def items(self):
-        return self._headers.items()
-
-    def addnamedtext(self, name, text):
-        assert isinstance(text, basestring)
-        assert isinstance(name, str)
-        self._blocknames.append(name)
-        self._blocks[name] = text
-
-    def getnamedtext(self, name):
-        return self._blocks[name]
-
-    def repr_short_error(self):
-        if not self.isok():
-            if 'reportdiff' in self._blocks:
-                return "output comparison failed, see reportdiff"
-            else:
-                text = self.getnamedtext('stderr')
-                lines = text.strip().split('\n')
-                if lines:
-                    return lines[-1]
-
-    def repr_mimemessage(self):
-        from email.MIMEMultipart  import MIMEMultipart
-        from email.MIMEText  import MIMEText
-
-        outer = MIMEMultipart()
-        items = self._headers.items()
-        items.sort()
-        reprs = {}
-        for name, value in items:
-            assert ':' not in name
-            chars = map(ord, name)
-            assert min(chars) >= 33 and max(chars) <= 126
-            outer[name] = str(value)
-            if not isinstance(value, str):
-                typename = type(value).__name__
-                assert typename in vars(py.std.__builtin__)
-                reprs[name] = typename
-
-        outer['_reprs'] = repr(reprs)
-
-        for name in self._blocknames:
-            text = self._blocks[name]
-            m = MIMEText(text)
-            m.add_header('Content-Disposition', 'attachment', filename=name)
-            outer.attach(m)
-        return outer
-
-    def grep_nr(self,text,section='stdout'):
-        stdout = self._blocks[section]
-        find = re.search('%s(?P<nr>\d+)'%text,stdout)
-        if find:
-            return float(find.group('nr'))
-        return 0.
-
-    def ratio_of_passed(self):
-        if self.isok():
-            return 1.
-        elif self.istimeout():
-            return 0.
-        else:
-            nr = self.grep_nr('Ran ')
-            if nr > 0:
-                return (nr - (self.grep_nr('errors=') + 
self.grep_nr('failures=')))/nr
-            else:
-                passed = self.grep_nr('TestFailed: ',section='stderr')
-                run = self.grep_nr('TestFailed: \d+/',section='stderr')
-                if run > 0:
-                    return passed/run
-                else:
-                    run = self.grep_nr('TestFailed: \d+ of ',section='stderr')
-                    if run > 0 :
-                        return (run-passed)/run
-                    else:
-                        return 0.0
-
-    def isok(self):
-        return self['outcome'].lower() == 'ok'
-
-    def iserror(self):
-        return self['outcome'].lower()[:3] == 'err' or self['outcome'].lower() 
== 'fail'
-
-    def istimeout(self):
-        return self['outcome'].lower() == 't/o'
-
-# XXX backward compatibility
-def sanitize(msg, path):
-    if 'exit-status' in msg.keys():
-        return msg
-    f = open(str(path), 'r')
-    msg = f.read()
-    f.close()
-    for broken in ('exit status', 'cpu model', 'cpu mhz'):
-        valid = broken.replace(' ','-')
-        invalid = msg.find(broken+':')
-        msg = (msg[:invalid] + valid +
-               msg[invalid+len(valid):])
-    from email import message_from_string
-    msg = message_from_string(msg)
-    return msg
-
-def sanitize_reprs(reprs):
-    if 'exit status' in reprs:
-        reprs['exit-status'] = reprs.pop('exit status')
-
-class ResultFromMime(Result):
-    def __init__(self, path):
-        super(ResultFromMime, self).__init__(init=False)
-        f = open(str(path), 'r')
-        from email import message_from_file
-        msg = message_from_file(f)
-        f.close()
-        msg = sanitize(msg, path)
-        # XXX security wise evil (keep in mind once we accept reporsts
-        # from anonymous
-        #print msg['_reprs']
-        self._reprs = eval(msg['_reprs'])
-        del msg['_reprs']
-        sanitize_reprs(self._reprs)
-        for name, value in msg.items():
-            if name in self._reprs:
-                value = eval(value)  # XXX security
-            self._headers[name] = value
-        self.fspath = self['fspath']
-        if self['platform'] == 'win32' and '\\' in self.fspath:
-            self.testname = self.fspath.split('\\')[-1]
-        else:
-            self.testname = self.fspath.split('/')[-1]
-        #if sys.platform != 'win32' and '\\' in self.fspath:
-        #    self.fspath = py.path.local(self['fspath'].replace('\\'
-        self.path = path
-
-        payload = msg.get_payload()
-        if payload:
-            for submsg in payload:
-                assert submsg.get_content_type() == 'text/plain'
-                fn = submsg.get_filename()
-                assert fn
-                # XXX we need to deal better with encodings to
-                #     begin with
-                content = submsg.get_payload()
-                for candidate in 'utf8', 'latin1':
-                    try:
-                        text = unicode(content, candidate)
-                    except UnicodeDecodeError:
-                        continue
-                else:
-                    unicode(content, candidate)
-                self.addnamedtext(fn, text)
-
-    def ismodifiedtest(self):
-        # XXX we need proper cross-platform paths!
-        return 'modified' in self.fspath
-
-    def __repr__(self):
-        return '<%s (%s) %r rev=%s>' %(self.__class__.__name__,
-                                  self['outcome'],
-                                  self.fspath,
-                                  self['pypy-revision'])
-
-def stdinit(result):
-    import getpass
-    import socket
-    try:
-        username = getpass.getuser()
-    except:
-        username = 'unknown'
-    userhost = '%s@%s' % (username, socket.gethostname())
-    result['testreport-version'] = "1.1.1"
-    result['userhost'] = userhost
-    result['platform'] = sys.platform
-    result['python-version-info'] = sys.version_info
-    info = try_getcpuinfo()
-    if info is not None:
-        result['cpu-model'] = info.get('model name', "unknown")
-        result['cpu-mhz'] = info.get('cpu mhz', 'unknown')
-#
-#
-#
-def try_getcpuinfo():
-    if sys.platform.startswith('linux'):
-        cpuinfopath = py.path.local('/proc/cpuinfo')
-        if cpuinfopath.check(file=1):
-            d = {}
-            for line in cpuinfopath.readlines():
-                if line.strip():
-                    name, value = line.split(':', 1)
-                    name = name.strip().lower()
-                    d[name] = value.strip()
-            return d
diff --git a/pypy/tool/pytest/test/test_new_count.py 
b/pypy/tool/pytest/test/test_new_count.py
deleted file mode 100644
--- a/pypy/tool/pytest/test/test_new_count.py
+++ /dev/null
@@ -1,32 +0,0 @@
-
-import py
-#from pypy.tool.pytest.confpath import testresultdir
-from pypy.tool.pytest.result import ResultFromMime
-testpath = py.path.local(__file__).dirpath('data')
-
-class TestResultCache:
-
-    def test_timeout(self):
-        test = ResultFromMime(testpath.join('test___all__.txt'))
-        assert test.ratio_of_passed() == 0.
-
-    def test_passed(self):
-        test = ResultFromMime(testpath.join('test_sys.txt'))
-        assert test.ratio_of_passed() == 1.
-
-    def test_unittest_partial(self):
-        test = ResultFromMime(testpath.join('test_compile.txt'))
-        assert test.ratio_of_passed() == 10./15
-    
-    def test_doctest_of(self):
-        test = ResultFromMime(testpath.join('test_generators.txt'))
-        assert test.ratio_of_passed() == 133./154
-
-    def test_doctest_slash(self):
-        test = ResultFromMime(testpath.join('test_descr.txt'))
-        assert test.ratio_of_passed() == 65./92
-
-    def test_fail(self):
-        test = ResultFromMime(testpath.join('test_global.txt'))
-        assert test.ratio_of_passed() == 0.
-
diff --git a/pypy/tool/pytest/test/test_overview.py 
b/pypy/tool/pytest/test/test_overview.py
deleted file mode 100644
--- a/pypy/tool/pytest/test/test_overview.py
+++ /dev/null
@@ -1,23 +0,0 @@
-
-import py
-from pypy.tool.pytest.confpath import testresultdir 
-from pypy.tool.pytest.overview import ResultCache 
-
-class TestResultCache: 
-    def setup_class(cls): 
-        if not testresultdir.check(dir=1):
-            py.test.skip("testresult directory not checked out")
-        cls.rc = ResultCache(testresultdir) 
-        cls.rc.parselatest()
-
-    def test_getlatest_all(self): 
-        for type in 'error', 'timeout', 'ok': 
-            for name in self.rc.getnames(): 
-                result = self.rc.getlatest(name, **{type:1})
-                if result: 
-                    meth = getattr(result, 'is'+type)
-                    assert meth()
-
-    #def test_getlatest_datetime(self): 
-    #    result = self.rc.getlatest('test_datetime', ok=1) 
-    #    assert result
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to