Ticket #228: 228.patch

File 228.patch, 5.6 kB (added by dustin, 6 months ago)

updated patch against devel repository; doesn't pass tests

  • old-dustin/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): 
  • old-dustin/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() 
  • old-dustin/buildbot/steps/shell.py

    old new  
    425425            return [ word + " (" + filter + ")" ] 
    426426        else: 
    427427            return [ word ] 
     428 
     429class PerlModuleTest(Test): 
     430    command=["prove", "--lib", "lib", "-r", "t"] 
     431 
     432    def evaluateCommand(self, cmd): 
     433        lines = self.getLog('stdio').readlines() 
     434 
     435        re_test_result = re.compile("^(All tests successful)|(\d+)/(\d+) subtests failed|Files=\d+, Tests=(\d+),") 
     436 
     437        mos = map(lambda line: re_test_result.search(line), lines) 
     438        test_result_lines = [mo.groups() for mo in mos if mo] 
     439 
     440        if not test_result_lines: 
     441            return cmd.rc 
     442 
     443        test_result_line = test_result_lines[0] 
     444 
     445        success = test_result_line[0] 
     446 
     447        if success: 
     448            failed = 0 
     449 
     450            test_totals_line = test_result_lines[1] 
     451            total_str = test_totals_line[3] 
     452 
     453            rc = SUCCESS 
     454        else: 
     455            failed_str = test_result_line[1] 
     456            failed = int(failed_str) 
     457 
     458            total_str = test_result_line[2] 
     459 
     460            rc = FAILURE 
     461 
     462        total = int(total_str) 
     463        passed = total - failed 
     464 
     465        self.setStepProperty('tests-total', total) 
     466        self.setStepProperty('tests-failed', failed) 
     467        self.setStepProperty('tests-passed', passed) 
     468 
     469        self.warnings = failed 
     470 
     471        return rc 
  • old-dustin/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) 
  • old-dustin/docs/buildbot.texinfo

    old new  
    49274927* Compile::                      
    49284928* Test::                         
    49294929* TreeSize::                     
     4930* PerlModuleTest:: 
    49304931* SetProperty::                     
    49314932* Build Properties::             
    49324933@end menu 
     
    49944995aka 'KiB' or 'kibibytes') on the step's status text, and sets a build 
    49954996property named 'tree-size-KiB' with the same value. 
    49964997 
     4998@node PerlModuleTest, Build Properties, TreeSize, Simple ShellCommand Subclasses 
     4999@subsubsection PerlModuleTest 
     5000 
     5001@bsindex buildbot.steps.shell.PerlModuleTest 
     5002 
     5003This is a simple command that knows how to run tests of perl modules. 
     5004It parses the output to determine the number of tests passed and 
     5005failed and total number executed, saving the results for later query. 
     5006 
    49975007@node SetProperty 
    49985008@subsubsection SetProperty 
    49995009