-
Notifications
You must be signed in to change notification settings - Fork 347
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Microsoft.DotNet.Helix/Sdk/tools/azure-pipelines/reporter/formats/yaml.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
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).