New gdbgitdb.py file; improve result email; improve the way we save logs and sums

This commit is contained in:
Sergio Durigan Junior 2014-12-22 17:51:13 -05:00
parent 7e5c68d7ce
commit 555c6db4b0
3 changed files with 71 additions and 13 deletions

35
lib/gdbgitdb.py Normal file
View file

@ -0,0 +1,35 @@
# DB-like with git
from buildbot.steps.shell import ShellCommand
from sumfiles import get_web_base
import os.path
import git
class SaveGDBResults (ShellCommand):
name = 'save build results'
description = 'saving build results'
descriptionDone = 'saved build results'
command = ['true']
def __init__ (self, **kwargs):
BuildStep.__init__ (self, **kwargs)
def evaluateCommand (self, cmd):
rev = self.getProperty ('got_revision')
builder = self.getProperty ('buildername')
istry = self.getProperty ('isTryBuilder')
branch = self.getProperty ('branch')
repodir = os.path.join (get_web_base (), builder)
if branch is None:
branch = 'master'
if istry and istry == 'yes':
# Do nothing
return SUCCESS
try:
repo = git.Repo (path = repodir)
except git.InvalidGitRepositoryError:
repo = git.Repo.init (path = repodir)
git.index.add (['gdb.sum', 'gdb.log', '%s/baseline' % branch])
git.index.commit ('Log files for %s' % rev)
git.create_tag (rev)
return SUCCESS

View file

@ -18,6 +18,10 @@ def set_web_base(arg):
# So, use mkdir and not makedirs.
os.mkdir(gdb_web_base, 0755)
def get_web_base ():
global gdb_web_base
return gdb_web_base
class DejaResults(object):
def __init__(self):
object.__init__(self)
@ -42,12 +46,15 @@ class DejaResults(object):
test_name = nname
out_dict[test_name] = result
def _write_sum_file(self, sum_dict, subdir, filename):
def _write_sum_file(self, sum_dict, subdir, filename, is_baseline):
global gdb_web_base
bdir = os.path.join(gdb_web_base, subdir)
if not os.path.isdir(bdir):
os.makedirs(bdir, 0755)
fname = os.path.join(bdir, filename)
if is_baseline:
fname = os.path.join(bdir, filename)
else:
fname = os.path.join(bdir, 'gdb.sum')
keys = sum_dict.keys()
keys.sort()
f = open(fname, 'w')
@ -56,11 +63,11 @@ class DejaResults(object):
f.close()
def write_sum_file(self, sum_dict, builder, filename):
self._write_sum_file(sum_dict, builder, filename)
self._write_sum_file(sum_dict, builder, filename, False)
def write_baseline(self, sum_dict, builder, branch):
self.write_sum_file(sum_dict, os.path.join(builder, branch),
'baseline')
'baseline', True)
# Read a .sum file.
# The builder name is BUILDER.
@ -68,9 +75,12 @@ class DejaResults(object):
# revision; to read the baseline file for a branch, use `read_baseline'.
# Returns a dictionary holding the .sum contents, or None if the
# file did not exist.
def read_sum_file(self, builder, filename):
def _read_sum_file(self, builder, filename, is_baseline):
global gdb_web_base
fname = os.path.join(gdb_web_base, builder, filename)
if is_baseline:
fname = os.path.join(gdb_web_base, builder, filename)
else:
fname = os.path.join(gdb_web_base, builder, 'gdb.sum')
if os.path.exists(fname):
result = {}
f = open(fname, 'r')
@ -81,8 +91,11 @@ class DejaResults(object):
result = None
return result
def read_sum_file (self, builder, filename):
return self._read_sum_file (self, builder, filename, False)
def read_baseline(self, builder, branch):
return self.read_sum_file(builder, os.path.join(branch, 'baseline'))
return self._read_sum_file(builder, os.path.join(branch, 'baseline'), True)
# Parse some text as a .sum file and return the resulting
# dictionary.
@ -100,7 +113,7 @@ class DejaResults(object):
our_keys = results.keys()
our_keys.sort()
result = ''
xfails = self.read_sum_file(builder, 'xfail')
xfails = self.read_sum_file(builder, 'xfail', False)
if xfails is None:
xfails = {}
for key in our_keys:

View file

@ -18,10 +18,13 @@ from buildbot.steps.shell import Compile
from buildbot.steps.shell import Configure
from buildbot.steps.shell import ShellCommand
from buildbot.steps.shell import SetPropertyFromCommand
from buildbot.steps.transfer import FileUpload
from buildbot.steps.source.git import Git
from buildbot.steps.slave import RemoveDirectory
from buildbot.changes.filter import ChangeFilter
from buildbot.buildslave import BuildSlave
from gdbcommand import GdbCatSumfileCommand
from gdbgitdb import SaveGDBResults
from sumfiles import DejaResults, set_web_base
import os.path
@ -108,11 +111,12 @@ send to the gdb-testers mailing list."""
ss_list = build.getSourceStamps ()
subj = "Failures on %s" % name
text = ""
parser = DejaResults ()
text += ("Commit(s) tested:\n")
text += "Builder:\n"
text += "\t%s\n" % build.getSlavename ()
text += "Commit(s) tested:\n"
for ss in ss_list:
text += ("\t%s\n" % ss.revision)
text += ("\n")
text += "\t%s\n" % ss.revision
text += "\n"
for log in build.getLogs ():
if log.getName () == 'regressions' and log.hasContents ():
text += log.getText ()
@ -340,7 +344,9 @@ class BuildAndTestGDBFactory (factory.BuildFactory):
def __init__ (self, architecture_triplet = []):
factory.BuildFactory.__init__ (self)
self.addStep (DeleteGDBBuildDir ())
self.addStep (RemoveDirectory (dir = WithProperties ("%s/build",
'builddir'))
# self.addStep (DeleteGDBBuildDir ())
# Unfortunately we need to have this random wait, otherwise
# git fetch won't work
self.addStep (RandomWaitForClone ())
@ -373,6 +379,10 @@ class BuildAndTestGDBFactory (factory.BuildFactory):
self.addStep (GdbCatSumfileCommand (workdir = WithProperties ('%s/build/gdb/testsuite',
'builddir'),
description = 'analyze test results'))
self.addStep (transfer.FileUpload (slavesrc = WithProperties ("%s/build/gdb/testsuite/gdb.log", 'builddir'),
masterdest = gdb_web_base + WithProperties ("/%s/gdb.log", 'buildername'),
hideStepIf = False))
self.addStep (SaveGDBResults ())
##################