Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge-on-Red: Implemented YAML log reader alongside the XML ones #11807

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from .xunit import XUnitFormat
from .junit import JUnitFormat
from .trx import TRXFormat
from .yaml import YAMLFormat


all_formats = [
XUnitFormat(),
JUnitFormat(),
TRXFormat()
TRXFormat(),
YAMLFormat()
] # type: List[ResultFormat]
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import yaml

from .result_format import ResultFormat
from helix.public import TestResult, TestResultAttachment

class YAMLFormat(ResultFormat):

def __init__(self):
super(YAMLFormat, self).__init__()
pass

@property
def name(self):
return 'yaml'

@property
def acceptable_file_suffixes(self):
yield 'testResults.yml'
yield 'test-results.yml'
yield 'test_results.yml'

# Work in Progress :)
def read_results(self, path):
contents = None
with open(path) as fh:
contents = yaml.safe_load(fh)

results = contents.get("assemblies").get("assembly").get("collection").get("tests")

for test in results:
name = test.get("name")
type_name = test.get("type")
method = test.get("method")
time = float(test.get("time"))
result = test.get("result")
exception_type = None
failure_message = None
stack_trace = None
skip_reason = None
attachments = []

failure_element = test.find("failure")

if failure_element is not None:
exception_type = failure_element.get("exception-type")
failure_message = failure_element.find("message")
stack_trace = failure_element.find("stack-trace")

output_element = test.find("output")

if output_element is not None:
attachments.append(TestResultAttachment(
name=u"Console_Output.log",
text=output_element,
))

skip_reason = test.find("reason")
res = TestResult(name, u'yaml', type_name, method, time, result, exception_type,
failure_message, stack_trace, skip_reason, attachments)
yield res
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we discussed that we need some sort of terminal detection. To make sure that the tests actually finished, and didn't just abort in the middle. Presumably it can go at the end here, and just be something like

if not contents.get("completed"):
    yield TestResult("TEST CRASH"...)

I'm not sure what a good name for the fake test is, since you'd presumably want it to be different for different workitems (so that you didn't just get a bunch of "TEST CRASH" tests that you can't tell which actual test execution they are bound to).