Create bot friendly sanity output. (#22381)

This commit is contained in:
Matt Clay 2017-03-07 14:59:50 -08:00 committed by GitHub
parent 3c69cf6d7d
commit 8f463fcdd2
4 changed files with 53 additions and 9 deletions

1
.gitignore vendored
View file

@ -72,6 +72,7 @@ packaging/release/ansible_release
/test/results/coverage/coverage*
/test/results/reports/coverage.xml
/test/results/reports/coverage/
/test/results/bot/*.json
/test/results/junit/*.xml
/test/results/logs/*.log
/test/integration/inventory.remote

0
test/results/bot/.keep Normal file
View file

View file

@ -564,6 +564,7 @@ class SanityResult(object):
:type args: SanityConfig
"""
self.write_console()
self.write_bot(args)
if args.lint:
self.write_lint()
@ -582,12 +583,33 @@ class SanityResult(object):
"""Write lint results to stdout."""
pass
def write_bot(self, args):
"""
:type args: SanityConfig
"""
pass
def write_junit(self, args):
"""
:type args: SanityConfig
"""
pass
def create_path(self, directory, extension):
"""
:type directory: str
:type extension: str
:rtype: str
"""
path = 'test/results/%s/ansible-test-%s' % (directory, self.test)
if self.python_version:
path += '-python-%s' % self.python_version
path += extension
return path
def save_junit(self, args, test_case, properties=None):
"""
:type args: SanityConfig
@ -595,12 +617,7 @@ class SanityResult(object):
:type properties: dict[str, str] | None
:rtype: str | None
"""
path = 'test/results/junit/ansible-test-%s' % self.test
if self.python_version:
path += '-python-%s' % self.python_version
path += '.xml'
path = self.create_path('junit', '.xml')
test_suites = [
self.junit.TestSuite(
@ -704,9 +721,6 @@ class SanityFailure(SanityResult):
title = self.format_title()
output = self.format_block()
# Hack to remove ANSI color reset code from SubprocessError messages.
output = output.replace(display.clear, '')
test_case = self.junit.TestCase(classname='sanity', name=self.test)
# Include a leading newline to improve readability on Shippable "Tests" tab.
@ -715,6 +729,31 @@ class SanityFailure(SanityResult):
self.save_junit(args, test_case)
def write_bot(self, args):
"""
:type args: SanityConfig
"""
message = self.format_title()
output = self.format_block()
bot_data = dict(
results=[
dict(
message=message,
output=output,
),
],
)
path = self.create_path('bot', '.json')
if args.explain:
return
with open(path, 'wb') as bot_fd:
json.dump(bot_data, bot_fd, indent=4, sort_keys=True)
bot_fd.write('\n')
def format_command(self):
"""
:rtype: str
@ -752,6 +791,9 @@ class SanityFailure(SanityResult):
message = block.strip()
# Hack to remove ANSI color reset code from SubprocessError messages.
message = message.replace(display.clear, '')
return message

View file

@ -35,6 +35,7 @@ function cleanup
rmdir shippable/testresults/
cp -a test/results/junit/ shippable/testresults/
cp -aT test/results/bot/ shippable/testresults/
}
trap cleanup EXIT