Added a custom UnitTest Step class, for the django test steps.
- Legacy-Id: 9254
This commit is contained in:
parent
9217759958
commit
5f38c12de4
|
@ -50,7 +50,6 @@ c['change_source'] = [
|
||||||
# case, just kick off a 'runtests' build
|
# case, just kick off a 'runtests' build
|
||||||
|
|
||||||
from buildbot.schedulers.basic import SingleBranchScheduler, AnyBranchScheduler
|
from buildbot.schedulers.basic import SingleBranchScheduler, AnyBranchScheduler
|
||||||
from buildbot.schedulers.forcesched import ForceScheduler
|
|
||||||
from buildbot.changes import filter
|
from buildbot.changes import filter
|
||||||
c['schedulers'] = [
|
c['schedulers'] = [
|
||||||
AnyBranchScheduler(name="pyflakes", treeStableTimer=10, builderNames=["Check PyFlakes"]),
|
AnyBranchScheduler(name="pyflakes", treeStableTimer=10, builderNames=["Check PyFlakes"]),
|
||||||
|
@ -85,6 +84,70 @@ class TestCrawlerShellCommand(WarningCountingShellCommand):
|
||||||
command=["bin/test-crawl"]
|
command=["bin/test-crawl"]
|
||||||
warningPattern = '.* FAIL'
|
warningPattern = '.* FAIL'
|
||||||
|
|
||||||
|
class UnitTest(WarningCountingShellCommand):
|
||||||
|
|
||||||
|
name = "test"
|
||||||
|
warnOnFailure = 1
|
||||||
|
description = ["testing"]
|
||||||
|
descriptionDone = ["test"]
|
||||||
|
command = ["python", "-m", "unittest", "discover"]
|
||||||
|
|
||||||
|
regexPatterns = {
|
||||||
|
"total": "Ran (\d+) tests in [0-9.]+s",
|
||||||
|
"time": "Ran \d+ tests in ([0-9.]+)s",
|
||||||
|
"skipped": "(?:OK|FAILED).*\skipped=(\d+)",
|
||||||
|
"failed": "FAILED.*failures\=(\d+)",
|
||||||
|
"errors": "FAILED.*errors\=(\d+)",
|
||||||
|
"template_coverage":" *Template coverage: +([0-9.]+%)",
|
||||||
|
"url_coverage": " *Url coverage: +([0-9.]+%)",
|
||||||
|
"code_coverage": " *Code coverage: +([0-9.]+%)",
|
||||||
|
}
|
||||||
|
|
||||||
|
def setTestResults(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Called by subclasses to set the relevant statistics; this actually
|
||||||
|
adds to any statistics already present
|
||||||
|
"""
|
||||||
|
for kw in kwargs:
|
||||||
|
value = kwargs[kw]
|
||||||
|
if value.isdigit():
|
||||||
|
# Counter
|
||||||
|
value = int(value)
|
||||||
|
value += self.step_status.getStatistic(kw, 0)
|
||||||
|
elif re.match("[0-9]+\.[0-9]+$"):
|
||||||
|
# Runtime
|
||||||
|
value = float(value)
|
||||||
|
value += self.step_status.getStatistic(kw, 0)
|
||||||
|
else:
|
||||||
|
# This is a percentage, and we can't add them
|
||||||
|
pass
|
||||||
|
self.step_status.setStatistic(kw, value)
|
||||||
|
|
||||||
|
def createSummary(self, log):
|
||||||
|
info = {}
|
||||||
|
for line in log.getText().split("\n"):
|
||||||
|
for key in regexPatterns:
|
||||||
|
regex = regexPatterns[key]
|
||||||
|
match = re.match(regex, line)
|
||||||
|
if match:
|
||||||
|
info[key] = match.group(1)
|
||||||
|
self.setTestResults(**info)
|
||||||
|
|
||||||
|
def describe(self, done=False):
|
||||||
|
description = WarningCountingShellCommand.describe(self, done)
|
||||||
|
if done:
|
||||||
|
description = description[:] # make a private copy
|
||||||
|
for name in self.step_status.statistics:
|
||||||
|
value = self.step_status.getStatistic(name)
|
||||||
|
if type(value) is float: # this is run-time
|
||||||
|
description.append('%.2fs %s' % (value, name))
|
||||||
|
elif type(value) is int:
|
||||||
|
description.append('%d %s' % (value, name))
|
||||||
|
else:
|
||||||
|
description.append('%s %s' % (value, name))
|
||||||
|
return description
|
||||||
|
|
||||||
|
|
||||||
## Set up builders
|
## Set up builders
|
||||||
|
|
||||||
c['builders'] = []
|
c['builders'] = []
|
||||||
|
@ -139,7 +202,7 @@ factory.addStep(ShellCommand(
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
command=["pip", "install", "-r", "requirements.txt"],
|
command=["pip", "install", "-r", "requirements.txt"],
|
||||||
))
|
))
|
||||||
factory.addStep(Test(
|
factory.addStep(UnitTest(
|
||||||
workdir=Interpolate('build/%(src::branch)s'),
|
workdir=Interpolate('build/%(src::branch)s'),
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
command=["ietf/manage.py", "test", "--settings=settings_sqlitetest"],
|
command=["ietf/manage.py", "test", "--settings=settings_sqlitetest"],
|
||||||
|
@ -173,7 +236,7 @@ factory.addStep(ShellCommand(
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
command=["pip", "install", "-r", "requirements.txt"],
|
command=["pip", "install", "-r", "requirements.txt"],
|
||||||
))
|
))
|
||||||
factory.addStep(Test(
|
factory.addStep(UnitTest(
|
||||||
workdir=Interpolate('build/%(src::branch)s'),
|
workdir=Interpolate('build/%(src::branch)s'),
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
command=["ietf/manage.py", "test", "--settings=settings_sqlitetest"],
|
command=["ietf/manage.py", "test", "--settings=settings_sqlitetest"],
|
||||||
|
|
Loading…
Reference in a new issue