| 1 |
{ |
|---|
| 2 |
hunk ./buildbot/process/buildstep.py 635 |
|---|
| 3 |
+ def getPropertyOrDefault(self, propname, default): |
|---|
| 4 |
+ return self.build.getPropertyOrDefault(propname, default) |
|---|
| 5 |
+ |
|---|
| 6 |
hunk ./buildbot/process/buildstep.py 641 |
|---|
| 7 |
+ def getStepProperty(self, propname): |
|---|
| 8 |
+ return self.step_status.getStepProperty(propname) |
|---|
| 9 |
+ |
|---|
| 10 |
+ def getStepPropertyOrDefault(self, propname, default): |
|---|
| 11 |
+ return self.step_status.getStepPropertyOrDefault(propname, default) |
|---|
| 12 |
+ |
|---|
| 13 |
+ def setStepProperty(self, propname, value): |
|---|
| 14 |
+ self.step_status.setStepProperty(propname, value) |
|---|
| 15 |
+ |
|---|
| 16 |
hunk ./buildbot/process/factory.py 7 |
|---|
| 17 |
-from buildbot.steps.shell import Configure, Compile, Test |
|---|
| 18 |
+from buildbot.steps.shell import Configure, Compile, Test, PerlModuleTest |
|---|
| 19 |
hunk ./buildbot/process/factory.py 84 |
|---|
| 20 |
- self.addStep(Test, command=["make", "test"]) |
|---|
| 21 |
+ self.addStep(PerlModuleTest, command=["make", "test"]) |
|---|
| 22 |
hunk ./buildbot/status/builder.py 673 |
|---|
| 23 |
+ properties = {} |
|---|
| 24 |
hunk ./buildbot/status/builder.py 683 |
|---|
| 25 |
+ self.properties = {} |
|---|
| 26 |
hunk ./buildbot/status/builder.py 711 |
|---|
| 27 |
+ def getStepProperty(self, propname): |
|---|
| 28 |
+ return self.properties[propname] |
|---|
| 29 |
+ |
|---|
| 30 |
+ def getStepPropertyOrDefault(self, propname, default): |
|---|
| 31 |
+ if self.properties.has_key(propname): |
|---|
| 32 |
+ return self.properties[propname] |
|---|
| 33 |
+ else: |
|---|
| 34 |
+ return default |
|---|
| 35 |
+ |
|---|
| 36 |
hunk ./buildbot/status/builder.py 813 |
|---|
| 37 |
+ def setStepProperty(self, propname, value): |
|---|
| 38 |
+ self.properties[propname] = value |
|---|
| 39 |
+ |
|---|
| 40 |
hunk ./buildbot/status/builder.py 903 |
|---|
| 41 |
+import operator |
|---|
| 42 |
+ |
|---|
| 43 |
hunk ./buildbot/status/builder.py 956 |
|---|
| 44 |
+ def getPropertyOrDefault(self, propname, default): |
|---|
| 45 |
+ if self.properties.has_key(propname): |
|---|
| 46 |
+ return self.properties[propname] |
|---|
| 47 |
+ else: |
|---|
| 48 |
+ return default |
|---|
| 49 |
+ |
|---|
| 50 |
hunk ./buildbot/status/builder.py 1048 |
|---|
| 51 |
+ def sumStepProperty(self, propname): |
|---|
| 52 |
+ return reduce(operator.add, map(lambda x: x.getStepPropertyOrDefault(propname, 0), self.steps)) |
|---|
| 53 |
+ |
|---|
| 54 |
hunk ./buildbot/status/web/waterfall.py 113 |
|---|
| 55 |
+ tests_failed = b.sumStepProperty('tests-failed') |
|---|
| 56 |
+ if tests_failed: text.extend(["Failed tests: %d" % tests_failed]) |
|---|
| 57 |
hunk ./buildbot/steps/shell.py 338 |
|---|
| 58 |
+class PerlModuleTest(Test): |
|---|
| 59 |
+ command=["prove", "--lib", "lib", "-r", "t"] |
|---|
| 60 |
+ |
|---|
| 61 |
+ def evaluateCommand(self, cmd): |
|---|
| 62 |
+ lines = self.getLog('stdio').readlines() |
|---|
| 63 |
+ |
|---|
| 64 |
+ re_test_result = re.compile("^(All tests successful)|(\d+)/(\d+) subtests failed|Files=\d+, Tests=(\d+),") |
|---|
| 65 |
+ |
|---|
| 66 |
+ mos = map(lambda line: re_test_result.search(line), lines) |
|---|
| 67 |
+ test_result_lines = [mo.groups() for mo in mos if mo] |
|---|
| 68 |
+ |
|---|
| 69 |
+ if not test_result_lines: |
|---|
| 70 |
+ return cmd.rc |
|---|
| 71 |
+ |
|---|
| 72 |
+ test_result_line = test_result_lines[0] |
|---|
| 73 |
+ |
|---|
| 74 |
+ success = test_result_line[0] |
|---|
| 75 |
+ |
|---|
| 76 |
+ if success: |
|---|
| 77 |
+ failed = 0 |
|---|
| 78 |
+ |
|---|
| 79 |
+ test_totals_line = test_result_lines[1] |
|---|
| 80 |
+ total_str = test_totals_line[3] |
|---|
| 81 |
+ |
|---|
| 82 |
+ rc = SUCCESS |
|---|
| 83 |
+ else: |
|---|
| 84 |
+ failed_str = test_result_line[1] |
|---|
| 85 |
+ failed = int(failed_str) |
|---|
| 86 |
+ |
|---|
| 87 |
+ total_str = test_result_line[2] |
|---|
| 88 |
+ |
|---|
| 89 |
+ rc = FAILURE |
|---|
| 90 |
+ |
|---|
| 91 |
+ total = int(total_str) |
|---|
| 92 |
+ passed = total - failed |
|---|
| 93 |
+ |
|---|
| 94 |
+ self.setStepProperty('tests-total', total) |
|---|
| 95 |
+ self.setStepProperty('tests-failed', failed) |
|---|
| 96 |
+ self.setStepProperty('tests-passed', passed) |
|---|
| 97 |
+ |
|---|
| 98 |
+ self.warnings = failed |
|---|
| 99 |
+ |
|---|
| 100 |
+ return rc |
|---|
| 101 |
+ |
|---|
| 102 |
hunk ./buildbot/test/test_status.py 984 |
|---|
| 103 |
+class Properties(unittest.TestCase): |
|---|
| 104 |
+ def testProperties(self): |
|---|
| 105 |
+ status = builder.BuildStatus(builder.BuilderStatus("test"), 123) |
|---|
| 106 |
+ status.addStepWithName('step1') |
|---|
| 107 |
+ status.addStepWithName('step2') |
|---|
| 108 |
+ status.addStepWithName('step3') |
|---|
| 109 |
+ status.addStepWithName('step4') |
|---|
| 110 |
+ |
|---|
| 111 |
+ steps = status.getSteps() |
|---|
| 112 |
+ (step1, step2, step3, step4) = steps |
|---|
| 113 |
+ |
|---|
| 114 |
+ step1.setStepProperty('test-prop', 1) |
|---|
| 115 |
+ step1.setStepProperty('other-prop', 27) # Just to have some other properties around |
|---|
| 116 |
+ step3.setStepProperty('test-prop', 2) |
|---|
| 117 |
+ step4.setStepProperty('test-prop', 4) |
|---|
| 118 |
+ |
|---|
| 119 |
+ self.failUnlessEqual(step1.getStepProperty('test-prop'), 1, 'Retrieve an existing property') |
|---|
| 120 |
+ self.failUnlessEqual(step1.getStepPropertyOrDefault('test-prop', 99), 1, 'Don\'t default an existing property') |
|---|
| 121 |
+ self.failUnlessEqual(step2.getStepPropertyOrDefault('test-prop', 99), 99, 'Default a non-existant property') |
|---|
| 122 |
+ |
|---|
| 123 |
+ self.failUnlessEqual( status.sumStepProperty('test-prop'), 7, 'Sum property across the build') |
|---|
| 124 |
+ |
|---|
| 125 |
hunk ./buildbot/test/test_steps.py 643 |
|---|
| 126 |
+class PerlModuleTest(StepTester, unittest.TestCase): |
|---|
| 127 |
+ def testAllTestsPassed(self): |
|---|
| 128 |
+ self.masterbase = "Warnings.testAllTestsPassed" |
|---|
| 129 |
+ step = self.makeStep(shell.PerlModuleTest) |
|---|
| 130 |
+ output = \ |
|---|
| 131 |
+"""ok 1 |
|---|
| 132 |
+ok 2 |
|---|
| 133 |
+All tests successful |
|---|
| 134 |
+Files=1, Tests=123, other stuff |
|---|
| 135 |
+""" |
|---|
| 136 |
+ log = step.addLog("stdio") |
|---|
| 137 |
+ log.addStdout(output) |
|---|
| 138 |
+ log.finish() |
|---|
| 139 |
+ step.evaluateCommand(log) |
|---|
| 140 |
+ self.failUnlessEqual(step.getStepProperty('tests-failed'), 0) |
|---|
| 141 |
+ self.failUnlessEqual(step.getStepProperty('tests-total'), 123) |
|---|
| 142 |
+ self.failUnlessEqual(step.getStepProperty('tests-passed'), 123) |
|---|
| 143 |
+ |
|---|
| 144 |
+ def testFailures(self): |
|---|
| 145 |
+ self.masterbase = "Warnings.testFailures" |
|---|
| 146 |
+ step = self.makeStep(shell.PerlModuleTest) |
|---|
| 147 |
+ output = \ |
|---|
| 148 |
+""" |
|---|
| 149 |
+ok 1 |
|---|
| 150 |
+ok 2 |
|---|
| 151 |
+3/7 subtests failed |
|---|
| 152 |
+""" |
|---|
| 153 |
+ log = step.addLog("stdio") |
|---|
| 154 |
+ log.addStdout(output) |
|---|
| 155 |
+ log.finish() |
|---|
| 156 |
+ step.evaluateCommand(log) |
|---|
| 157 |
+ self.failUnlessEqual(step.getStepProperty('tests-failed'), 3) |
|---|
| 158 |
+ self.failUnlessEqual(step.getStepProperty('tests-total'), 7) |
|---|
| 159 |
+ self.failUnlessEqual(step.getStepProperty('tests-passed'), 4) |
|---|
| 160 |
+ |
|---|
| 161 |
hunk ./docs/buildbot.texinfo 4478 |
|---|
| 162 |
+* PerlModuleTest:: |
|---|
| 163 |
hunk ./docs/buildbot.texinfo 4535 |
|---|
| 164 |
-@node TreeSize, Build Properties, Test, Simple ShellCommand Subclasses |
|---|
| 165 |
+@node TreeSize, PerlModuleTest, Test, Simple ShellCommand Subclasses |
|---|
| 166 |
hunk ./docs/buildbot.texinfo 4545 |
|---|
| 167 |
+@node PerlModuleTest, Build Properties, TreeSize, Simple ShellCommand Subclasses |
|---|
| 168 |
+@subsubsection PerlModuleTest |
|---|
| 169 |
hunk ./docs/buildbot.texinfo 4548 |
|---|
| 170 |
-@node Build Properties, , TreeSize, Simple ShellCommand Subclasses |
|---|
| 171 |
+@bsindex buildbot.steps.shell.PerlModuleTest |
|---|
| 172 |
+ |
|---|
| 173 |
+This is a simple command that knows how to run tests of perl modules. |
|---|
| 174 |
+It parses the output to determine the number of tests passed and |
|---|
| 175 |
+failed and total number executed, saving the results for later query. |
|---|
| 176 |
+ |
|---|
| 177 |
+ |
|---|
| 178 |
+@node Build Properties, , PerlModuleTest, Simple ShellCommand Subclasses |
|---|
| 179 |
} |
|---|