Changeset fbfc3b in indico


Ignore:
Timestamp:
06/18/10 18:55:12 (3 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
d160015
Parents:
e65840
git-author:
Jeremy Nguyen Xuan <jeremy.nguyen.xuan@…> (01/08/10 09:36:39)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (06/18/10 18:55:12)
Message:

[FIX] Pylint configuration and Jsunit

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • indicop/Indicop.py

    re65840 rfbfc3b  
    3434 
    3535 
    36 class Indicop(object): 
     36class BaseTest(object):         
    3737    #path to this current file 
    3838    setupDir = os.path.dirname(__file__) 
     
    4343        f.close() 
    4444 
    45     def main(self, specify, coverage, jsSpecify, jsCoverage, testsToRun): 
    46          
    47         #define the set of tests 
    48         testsDict = {'unit': Unit(), 
    49                      'functional': Functional(), 
    50                      'pylint': Pylint(), 
    51                      'jsunit': Jsunit(jsSpecify, jsCoverage), 
    52                      'jslint': Jslint()} 
    53          
    54         returnString = "\n\n=============== ~INDICOP SAYS~ ===============\n\n" 
    55          
    56         if coverage: 
    57             figleaf.start() 
    58              
    59          
    60         #specified test can either be unit or functional. 
    61         #It makes more sense to run it here. 
    62         if specify: 
    63             #running directly the test here and ouputing in the console 
    64             result = nose.run(argv=['nose', '-v', os.path.join(self.setupDir, 
    65                                                                'python', 
    66                                                                specify)]) 
    67             if result: 
    68                 returnString += "Specified Test - Succeeded\n" 
    69             else: 
    70                 returnString += "[FAIL] Specified Test - \ 
    71                                     read output from console\n" 
    72         else: 
    73             for test in testsToRun: 
    74                 try: 
    75                     returnString += testsDict[test].run() 
    76                 except KeyError: 
    77                     returnString += ("[ERR] Test %s does not exist. " 
    78                       "It has to be added in the testsDict variable\n") % test 
    79          
    80          
    81         if coverage: 
    82             figleaf.stop() 
    83             coverageOutput = figleaf.get_data().gather_files() 
    84             coverageDir = os.path.join(self.setupDir, 'report', 'pycoverage') 
    85             try: 
    86                 figleaf.annotate_html.report_as_html(coverageOutput, 
    87                                                      coverageDir, [], {}) 
    88             except IOError: 
    89                 os.mkdir(coverageDir) 
    90                 figleaf.annotate_html.report_as_html(coverageOutput, 
    91                                                      coverageDir, [], {}) 
    92             returnString += ("PY Unit Test - Report generated in " 
    93                              "report/pycoverage/index.html\n") 
    94              
    95          
    96         return returnString 
    97  
    98  
    99 class Unit(Indicop): 
     45class Unit(BaseTest): 
    10046    def run(self): 
    10147        #capturing the stderr 
     
    11965            return "[FAIL] Unit tests - report in indicop/report/pyunit.txt\n" 
    12066 
    121 class Functional(Indicop): 
     67class Functional(BaseTest): 
    12268    def run(self): 
    12369        try: 
     
    176122        return report 
    177123     
    178 class Pylint(Indicop): 
     124class Pylint(BaseTest): 
    179125    def run(self): 
    180126        statusOutput = commands.getstatusoutput("pylint --rcfile=%s %s" %  
     
    194140            return "PY Lint - report in indicop/report/pylint.txt\n" 
    195141         
    196 class Jsunit(Indicop): 
     142class Coverage(BaseTest): 
     143    def start(self): 
     144        figleaf.start() 
     145     
     146    def stop(self): 
     147        figleaf.stop() 
     148        coverageOutput = figleaf.get_data().gather_files() 
     149        coverageDir = os.path.join(self.setupDir, 'report', 'pycoverage') 
     150        try: 
     151            figleaf.annotate_html.report_as_html(coverageOutput, 
     152                                                 coverageDir, [], {}) 
     153        except IOError: 
     154            os.mkdir(coverageDir) 
     155            figleaf.annotate_html.report_as_html(coverageOutput, 
     156                                                 coverageDir, [], {}) 
     157        return ("PY Unit Test - Report generated in " 
     158                             "report/pycoverage/index.html\n") 
     159         
     160class Jsunit(BaseTest): 
    197161    def __init__(self, jsSpecify, jsCoverage): 
    198162        self.coverage = jsCoverage 
     
    314278        return coverageReport + report 
    315279     
    316 class Jslint(Indicop): 
     280class Jslint(BaseTest): 
    317281    def run(self): 
    318282        #Folders which are going to be scanned. 
     
    352316        self.writeReport("jslint", outputString) 
    353317        return "JS Lint - report in indicop/report/jslint.txt\n" 
    354      
     318 
     319 
     320class Indicop(object): 
     321     
     322    def __init__(self, jsspecify, jscoverage): 
     323        #variables for jsunit 
     324        self.jsSpecify = jsspecify 
     325        self.jsCoverage = jscoverage 
     326         
     327        #define the set of tests 
     328        self.testsDict = {'unit': Unit(), 
     329                 'functional': Functional(), 
     330                 'pylint': Pylint(), 
     331                 'jsunit': Jsunit(self.jsSpecify, self.jsCoverage), 
     332                 'jslint': Jslint()} 
     333 
     334     
     335    def main(self, specify, coverage, testsToRun): 
     336         
     337        returnString = "\n\n=============== ~INDICOP SAYS~ ===============\n\n" 
     338         
     339        coverageTest = Coverage() 
     340        if coverage: 
     341            coverageTest.start() 
     342             
     343         
     344        #specified test can either be unit or functional. 
     345        #It makes more sense to run it here. 
     346        if specify: 
     347            #running directly the test here and ouputing in the console 
     348            result = nose.run(argv=['nose', '-v', os.path.join(self.setupDir, 
     349                                                               'python', 
     350                                                               specify)]) 
     351            if result: 
     352                returnString += "Specified Test - Succeeded\n" 
     353            else: 
     354                returnString += "[FAIL] Specified Test - \ 
     355                                    read output from console\n" 
     356        else: 
     357            for test in testsToRun: 
     358                try: 
     359                    returnString += self.testsDict[test].run() 
     360                except KeyError: 
     361                    returnString += ("[ERR] Test %s does not exist. " 
     362                      "It has to be added in the testsDict variable\n") % test 
     363         
     364         
     365        if coverage: 
     366            returnString += coverageTest.stop() 
     367         
     368        return returnString 
     369     
  • indicop/python/pylint/pylint.conf

    r3636c5 rfbfc3b  
    309309 
    310310# Maximum number of characters on a single line. 
    311 max-line-length=79 
     311max-line-length=85 
    312312 
    313313# Maximum number of lines in a module 
  • setup.py

    r3636c5 rfbfc3b  
    346346            testsToRun.append('jslint') 
    347347         
    348         result = Indicop().main(self.specify, self.coverage, self.jsspecify, self.jscoverage, testsToRun) 
     348        indicop = Indicop(self.jsspecify, self.jscoverage) 
     349        result = indicop.main(self.specify, self.coverage, testsToRun) 
    349350        print result 
    350351 
Note: See TracChangeset for help on using the changeset viewer.