Generate CDash reports for build/install step

This commit is contained in:
Zack Galbreath 2018-04-19 15:21:23 -04:00 committed by Todd Gamblin
parent ae0ba373b8
commit 847c1216d0
2 changed files with 60 additions and 2 deletions

View File

@ -23,6 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
"""Tools to produce reports of spec installations""" """Tools to produce reports of spec installations"""
import codecs
import collections import collections
import functools import functools
import itertools import itertools
@ -33,6 +34,7 @@
import time import time
import traceback import traceback
import xml.sax.saxutils import xml.sax.saxutils
from six import text_type
import llnl.util.lang import llnl.util.lang
import spack.build_environment import spack.build_environment
@ -294,7 +296,9 @@ def cdash_build_report(self, report_data):
'autoreconf': 'configure', 'autoreconf': 'configure',
'cmake': 'configure', 'cmake': 'configure',
'configure': 'configure', 'configure': 'configure',
'edit': 'configure' 'edit': 'configure',
'build': 'build',
'install': 'build'
} }
# Initialize data structures common to each phase's report. # Initialize data structures common to each phase's report.
@ -344,11 +348,38 @@ def cdash_build_report(self, report_data):
if phase == 'configure' and nerrors > 0: if phase == 'configure' and nerrors > 0:
report_data[phase]['status'] = 1 report_data[phase]['status'] = 1
if phase == 'build':
# Convert log output from ASCII to Unicode and escape for XML.
def clean_log_event(event):
event = vars(event)
event['text'] = xml.sax.saxutils.escape(event['text'])
event['pre_context'] = xml.sax.saxutils.escape(
'\n'.join(event['pre_context']))
event['post_context'] = xml.sax.saxutils.escape(
'\n'.join(event['post_context']))
# source_file and source_line_no are either strings or
# the tuple (None,). Distinguish between these two cases.
if event['source_file'][0] is None:
event['source_file'] = ''
event['source_line_no'] = ''
else:
event['source_file'] = xml.sax.saxutils.escape(
event['source_file'])
return event
report_data[phase]['errors'] = []
report_data[phase]['warnings'] = []
for error in errors:
report_data[phase]['errors'].append(clean_log_event(error))
for warning in warnings:
report_data[phase]['warnings'].append(
clean_log_event(warning))
# Write the report. # Write the report.
report_name = phase.capitalize() + ".xml" report_name = phase.capitalize() + ".xml"
phase_report = os.path.join(self.filename, report_name) phase_report = os.path.join(self.filename, report_name)
with open(phase_report, 'w') as f: with codecs.open(phase_report, 'w', 'utf-8') as f:
env = spack.tengine.make_environment() env = spack.tengine.make_environment()
site_template = os.path.join(templates[self.format_name], site_template = os.path.join(templates[self.format_name],
'Site.xml') 'Site.xml')

View File

@ -0,0 +1,27 @@
<Build>
<StartBuildTime>{{ build.starttime }}</StartBuildTime>
<BuildCommand>{{ install_command }}</BuildCommand>
{% for warning in build.warnings %}
<Warning>
<BuildLogLine>{{ warning.line_no }}</BuildLogLine>
<Text>{{ warning.text }}</Text>
<SourceFile>{{ warning.source_file }}</SourceFile>
<SourceLineNumber>{{ warning.source_line_no }}</SourceLineNumber>
<PreContext>{{ warning.pre_context }}</PreContext>
<PostContext>{{ warning.post_context }}</PostContext>
</Warning>
{% endfor %}
{% for error in build.errors %}
<Error>
<BuildLogLine>{{ error.line_no }}</BuildLogLine>
<Text>{{ error.text }}</Text>
<SourceFile>{{ error.source_file }}</SourceFile>
<SourceLineNumber>{{ error.source_line_no }}</SourceLineNumber>
<PreContext>{{ error.pre_context }}</PreContext>
<PostContext>{{ error.post_context }}</PostContext>
</Error>
{% endfor %}
<EndBuildTime>{{ build.endtime }}</EndBuildTime>
<ElapsedMinutes>0</ElapsedMinutes>
</Build>
</Site>