-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d89e794
Showing
5 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*~ | ||
.redcar | ||
*pyc | ||
_trial_temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
buildbot-dzil-steps | ||
=================== | ||
|
||
Buildbot build steps optimised for ant, the Java build tool. | ||
|
||
Currently only 'test' is implemented. | ||
|
||
Usage | ||
----- | ||
|
||
Firstly, download or clone the code and put it somewhere near your buildmaster. | ||
|
||
Then add the following (or similar): | ||
|
||
from ant import AntTest | ||
|
||
### AntTest() | ||
|
||
You can use this as follows: | ||
|
||
factory.addStep(AntTest()) | ||
|
||
It will run the `ant test` command in the build directory. The output is then parsed to get the test results, which are then displayed in your waterfall. | ||
|
||
It is a subclass of `Test`, and takes the same arguments. | ||
|
||
TODO | ||
---- | ||
- Upload JUnit HTML output |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import re | ||
from twisted.python import log | ||
|
||
from buildbot.status.results import SUCCESS, FAILURE, WARNINGS, SKIPPED | ||
from buildbot.steps.shell import Test | ||
|
||
class AntTest(Test): | ||
command=["ant", "test"] | ||
|
||
def evaluateCommand(self, cmd): | ||
# Get stdio, stripping pesky newlines etc. | ||
lines = map( | ||
lambda line : line.replace('\r\n','').replace('\r','').replace('\n',''), | ||
self.getLog('stdio').readlines() | ||
) | ||
|
||
total = 0 | ||
passed = 0 | ||
failed = 0 | ||
rc = SUCCESS | ||
if cmd.rc > 0: | ||
rc = FAILURE | ||
|
||
re_test_result = re.compile("Tests run: (\d+), Failures: (\d+), Errors: (\d+)") | ||
|
||
mos = map(lambda line: re_test_result.search(line), lines) | ||
test_result_lines = [mo.groups() for mo in mos if mo] | ||
|
||
if test_result_lines: | ||
test_result_line = test_result_lines[0] | ||
|
||
total = int(test_result_line[0]) | ||
#assertions = int(test_result_line[1]) # not currently used | ||
failed = int(test_result_line[1]) | ||
errors = int(test_result_line[2]) | ||
|
||
passed = total - (failed + errors) | ||
|
||
if failed or errors: | ||
rc = FAILURE | ||
|
||
warnings = 0 | ||
if self.warningPattern: | ||
wre = self.warningPattern | ||
if isinstance(wre, str): | ||
wre = re.compile(wre) | ||
|
||
warnings = len([l for l in lines if wre.search(l)]) | ||
|
||
if rc == SUCCESS and warnings: | ||
rc = WARNINGS | ||
|
||
self.setTestResults(total=total, failed=failed+errors, passed=passed, | ||
warnings=warnings) | ||
|
||
return rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import ant | ||
|
||
from twisted.trial import unittest | ||
from buildbot.status.results import SKIPPED, SUCCESS, WARNINGS, FAILURE | ||
from buildbot.test.util import steps, compat | ||
|
||
class FakeLogFile: | ||
def __init__(self, text): | ||
self.text = text | ||
|
||
def getText(self): | ||
return self.text | ||
|
||
class FakeCmd: | ||
def __init__(self, stdout, stderr, rc=0): | ||
self.logs = {'stdout': FakeLogFile(stdout), | ||
'stderr': FakeLogFile(stderr)} | ||
self.rc = rc | ||
|
||
class TestAnt(steps.BuildStepMixin, unittest.TestCase): | ||
|
||
def setUp(self): | ||
return self.setUpBuildStep() | ||
|
||
def tearDown(self): | ||
return self.tearDownBuildStep() | ||
|
||
def test_dzilPass(self): | ||
step = self.setupStep(ant.AntTest()) | ||
|
||
log = """junit: | ||
[mkdir] Created dir: /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/xml | ||
[junit] Running uk.co.arjones.ant.task.SitemapTest | ||
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.539 sec | ||
junitreport: | ||
[mkdir] Created dir: /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/html | ||
[junitreport] Processing /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/html/TESTS-TestSuites.xml to /var/folders/bv/4c_z4wmd7h92bc6llrm6fcgm0000gp/T/null1009356432 | ||
[junitreport] Loading stylesheet jar:file:/usr/share/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl | ||
[junitreport] Transform time: 552ms | ||
[junitreport] Deleting: /var/folders/bv/4c_z4wmd7h92bc6llrm6fcgm0000gp/T/null1009356432 | ||
test: | ||
BUILD SUCCESSFUL | ||
Total time: 3 seconds""" | ||
step.addCompleteLog('stdio', log) | ||
|
||
rc = step.evaluateCommand(FakeCmd("", "")) | ||
|
||
self.assertEqual(rc, SUCCESS) | ||
self.assertEqual(self.step_statistics, { | ||
'tests-total' : 1, | ||
'tests-failed' : 0, | ||
'tests-passed' : 1, | ||
'tests-warnings' : 0, | ||
}) | ||
|
||
def test_dzilFailure(self): | ||
step = self.setupStep(ant.AntTest()) | ||
|
||
log = """junit: | ||
[mkdir] Created dir: /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/xml | ||
[junit] Running uk.co.arjones.ant.task.SitemapTest | ||
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.539 sec | ||
junitreport: | ||
[mkdir] Created dir: /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/html | ||
[junitreport] Processing /Users/buildbot/oss-slave/ant-task-sitemap/build/report/junit/html/TESTS-TestSuites.xml to /var/folders/bv/4c_z4wmd7h92bc6llrm6fcgm0000gp/T/null1009356432 | ||
[junitreport] Loading stylesheet jar:file:/usr/share/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl | ||
[junitreport] Transform time: 552ms | ||
[junitreport] Deleting: /var/folders/bv/4c_z4wmd7h92bc6llrm6fcgm0000gp/T/null1009356432 | ||
test: | ||
BUILD SUCCESSFUL | ||
Total time: 3 seconds""" | ||
step.addCompleteLog('stdio', log) | ||
|
||
rc = step.evaluateCommand(FakeCmd("", "")) | ||
|
||
self.assertEqual(rc, FAILURE) | ||
self.assertEqual(self.step_statistics, { | ||
'tests-total' : 1, | ||
'tests-failed' : 1, | ||
'tests-passed' : 0, | ||
'tests-warnings' : 0, | ||
}) |