~ubuntu-branches/ubuntu/trusty/pylint/trusty

« back to all changes in this revision

Viewing changes to test/test_rpycompilation.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2009-03-27 09:45:39 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090327094539-xe2s86jkbvdv3xhb
Tags: 0.18.0-1
* New upstream release
* debian/copyright
  - added packaging copyright for the work I do
  - clearly separated copyright and license notices, indenting by 4 spaces
  - link to GPL-2 file, not to the generic GPL
* debian/control
  - updated Homepage field
  - bump versions for python-logilab-common and python-logilab-astng depends
  - bump Standard-Versions to 3.8.1 (no changes needed)
* debian/{control, rules}
  - switch from python-central to python-support
* debian/rules
  - 'build' is a dir, we need to clean with 'rm'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from os.path import isfile, splitext, basename
2
 
from os import system, remove
3
 
from glob import glob
4
 
 
5
 
from logilab.common.testlib import TestCase, unittest_main
6
 
 
7
 
class RPyCompilation(TestCase):
8
 
 
9
 
    def setUp(self):
10
 
        self.trscript = self.find_pypy()
11
 
 
12
 
    def find_pypy(self):
13
 
        #trscript = '/home/adim/local/svn/pypy-dist/pypy/translator/goal/translate.py'
14
 
        trscript = '/home/syt/cvs_work/pypy-dist/pypy/translator/goal/translate.py'
15
 
        if not isfile(trscript):
16
 
            self.skip('translate.py not found')
17
 
        return trscript
18
 
    
19
 
    def _compile_fail(self, filename):
20
 
        status = system('%s --batch %s' % (self.trscript, filename))
21
 
        try:
22
 
            self.assertNotEquals(status, 0, "%s translation succeed !!" % filename)
23
 
        except AssertionError:
24
 
            exefile = '%s-c' % splitext(basename(filename))[0]
25
 
            status = system('./%s' % exefile)
26
 
            remove(exefile)
27
 
            self.assertNotEquals(status, 0, "%s run succeed !!" % exefile)
28
 
            
29
 
    def _compile_success(self, filename):
30
 
        status = system('%s --batch %s' % (self.trscript, filename))
31
 
        self.assertEquals(status, 0, "%s translation failed !!" % filename)
32
 
        exefile = '%s-c' % splitext(basename(filename))[0]
33
 
        status = system('./%s' % exefile)
34
 
        remove(exefile)
35
 
        self.assertEquals(status, 0, "%s run failed !!" % exefile)
36
 
            
37
 
            
38
 
    def test_translations(self):
39
 
        for filename in glob('rpythoninput/func_*.py'):
40
 
            if filename.startswith('rpythoninput/func_noerror'):
41
 
                yield self._compile_success, filename
42
 
            else:
43
 
                yield self._compile_fail, filename
44
 
 
45
 
    
46
 
if __name__ == '__main__':
47
 
    import sys
48
 
    if not '-cc' in sys.argv:
49
 
        sys.argv.append('-cc')
50
 
    unittest_main()