Ticket #228: pmt.diff

File pmt.diff, 7.0 KB (added by nhemingway, 2 years ago)

darcs diff -u to add PerlModuleTest?

  • buildbot/process/factory.py

    diff -rN -u old-buildbot_only_PerlModuleTest/buildbot/process/factory.py new-buildbot_only_PerlModuleTest/buildbot/process/factory.py
    old new  
    44from buildbot.process.base import Build 
    55from buildbot.process.buildstep import BuildStep 
    66from buildbot.steps.source import CVS, SVN 
    7 from buildbot.steps.shell import Configure, Compile, Test 
     7from buildbot.steps.shell import Configure, Compile, Test, PerlModuleTest 
    88 
    99# deprecated, use BuildFactory.addStep 
    1010def s(steptype, **kwargs): 
     
    8181        BuildFactory.__init__(self, [source]) 
    8282        self.addStep(Configure, command=[perl, "Makefile.PL"]) 
    8383        self.addStep(Compile, command=["make"]) 
    84         self.addStep(Test, command=["make", "test"]) 
     84        self.addStep(PerlModuleTest, command=["make", "test"]) 
    8585 
    8686class Distutils(BuildFactory): 
    8787    def __init__(self, source, python="python", test=None): 
  • buildbot/status/web/waterfall.py

    diff -rN -u old-buildbot_only_PerlModuleTest/buildbot/status/web/waterfall.py new-buildbot_only_PerlModuleTest/buildbot/status/web/waterfall.py
    old new  
    110110        number = b.getNumber() 
    111111        url = path_to_build(req, b) 
    112112        text = b.getText() 
     113        tests_failed = b.sumStepProperty('tests-failed') 
     114        if tests_failed: text.extend(["Failed tests: %d" % tests_failed]) 
    113115        # TODO: maybe add logs? 
    114116        # TODO: add link to the per-build page at 'url' 
    115117        c = b.getColor() 
  • buildbot/steps/shell.py

    diff -rN -u old-buildbot_only_PerlModuleTest/buildbot/steps/shell.py new-buildbot_only_PerlModuleTest/buildbot/steps/shell.py
    old new  
    334334    description = ["testing"] 
    335335    descriptionDone = ["test"] 
    336336    command = ["make", "test"] 
     337 
     338class PerlModuleTest(Test): 
     339    command=["prove", "--lib", "lib", "-r", "t"] 
     340 
     341    def evaluateCommand(self, cmd): 
     342        lines = self.getLog('stdio').readlines() 
     343 
     344        re_test_result = re.compile("^(All tests successful)|(\d+)/(\d+) subtests failed|Files=\d+, Tests=(\d+),") 
     345 
     346        mos = map(lambda line: re_test_result.search(line), lines) 
     347        test_result_lines = [mo.groups() for mo in mos if mo] 
     348 
     349        if not test_result_lines: 
     350            return cmd.rc 
     351 
     352        test_result_line = test_result_lines[0] 
     353 
     354        success = test_result_line[0] 
     355 
     356        if success: 
     357            failed = 0 
     358 
     359            test_totals_line = test_result_lines[1] 
     360            total_str = test_totals_line[3] 
     361 
     362            rc = SUCCESS 
     363        else: 
     364            failed_str = test_result_line[1] 
     365            failed = int(failed_str) 
     366 
     367            total_str = test_result_line[2] 
     368 
     369            rc = FAILURE 
     370 
     371        total = int(total_str) 
     372        passed = total - failed 
     373 
     374        self.setStepProperty('tests-total', total) 
     375        self.setStepProperty('tests-failed', failed) 
     376        self.setStepProperty('tests-passed', passed) 
     377 
     378        self.warnings = failed 
     379 
     380        return rc 
  • buildbot/test/test_steps.py

    diff -rN -u old-buildbot_only_PerlModuleTest/buildbot/test/test_steps.py new-buildbot_only_PerlModuleTest/buildbot/test/test_steps.py
    old new  
    639639                                 "treesize %d KiB" % kib) 
    640640        d.addCallback(_check) 
    641641        return d 
     642 
     643class PerlModuleTest(StepTester, unittest.TestCase): 
     644    def testAllTestsPassed(self): 
     645        self.masterbase = "Warnings.testAllTestsPassed" 
     646        step = self.makeStep(shell.PerlModuleTest) 
     647        output = \ 
     648"""ok 1 
     649ok 2 
     650All tests successful 
     651Files=1, Tests=123, other stuff 
     652""" 
     653        log = step.addLog("stdio") 
     654        log.addStdout(output) 
     655        log.finish() 
     656        step.evaluateCommand(log) 
     657        self.failUnlessEqual(step.getStepProperty('tests-failed'), 0) 
     658        self.failUnlessEqual(step.getStepProperty('tests-total'), 123) 
     659        self.failUnlessEqual(step.getStepProperty('tests-passed'), 123) 
     660 
     661    def testFailures(self): 
     662        self.masterbase = "Warnings.testFailures" 
     663        step = self.makeStep(shell.PerlModuleTest) 
     664        output = \ 
     665""" 
     666ok 1 
     667ok 2 
     6683/7 subtests failed 
     669""" 
     670        log = step.addLog("stdio") 
     671        log.addStdout(output) 
     672        log.finish() 
     673        step.evaluateCommand(log) 
     674        self.failUnlessEqual(step.getStepProperty('tests-failed'), 3) 
     675        self.failUnlessEqual(step.getStepProperty('tests-total'), 7) 
     676        self.failUnlessEqual(step.getStepProperty('tests-passed'), 4) 
  • docs/buildbot.texinfo

    diff -rN -u old-buildbot_only_PerlModuleTest/docs/buildbot.texinfo new-buildbot_only_PerlModuleTest/docs/buildbot.texinfo
    old new  
    206206* Compile::                      
    207207* Test::                         
    208208* TreeSize::                     
    209 * Build Properties::             
     209* Build Properties:: 
    210210 
    211211Python BuildSteps 
    212212 
     
    44754475* Compile::                      
    44764476* Test::                         
    44774477* TreeSize::                     
    4478 * Build Properties::             
     4478* PerlModuleTest:: 
     4479* Build Properties:: 
    44794480@end menu 
    44804481 
    44814482@node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses 
     
    45314532This is meant to handle unit tests. The default command is @code{make 
    45324533test}, and the @code{warnOnFailure} flag is set. 
    45334534 
    4534 @node TreeSize, Build Properties, Test, Simple ShellCommand Subclasses 
     4535@node TreeSize, PerlModuleTest, Test, Simple ShellCommand Subclasses 
    45354536@subsubsection TreeSize 
    45364537 
    45374538@bsindex buildbot.steps.shell.TreeSize 
     
    45414542aka 'KiB' or 'kibibytes') on the step's status text, and sets a build 
    45424543property named 'tree-size-KiB' with the same value. 
    45434544 
     4545@node PerlModuleTest, Build Properties, TreeSize, Simple ShellCommand Subclasses 
     4546@subsubsection PerlModuleTest 
    45444547 
    4545 @node Build Properties,  , TreeSize, Simple ShellCommand Subclasses 
     4548@bsindex buildbot.steps.shell.PerlModuleTest 
     4549 
     4550This is a simple command that knows how to run tests of perl modules. 
     4551It parses the output to determine the number of tests passed and 
     4552failed and total number executed, saving the results for later query. 
     4553 
     4554 
     4555@node Build Properties, , PerlModuleTest, Simple ShellCommand Subclasses 
    45464556@subsubsection Build Properties 
    45474557 
    45484558@cindex build properties 
     
    53395349 
    53405350 
    53415351 
    5342 @node BuildStep URLs,  , Adding LogObservers, Writing New BuildSteps 
     5352@node BuildStep URLs, , Adding LogObservers, Writing New BuildSteps 
    53435353@subsubsection BuildStep URLs 
    53445354 
    53455355@cindex links