-
Notifications
You must be signed in to change notification settings - Fork 3
fix #207: assign diagnostic to correct test #209
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
Merged
Merged
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 hidden or 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 |
|---|---|---|
|
|
@@ -12,20 +12,26 @@ const durationRegex = /duration_ms\s([\d.]+)/ | |
| export default async function parseReport(source) { | ||
| const tests = [] | ||
| const testStack = [] | ||
|
|
||
| let diagnosticMessage = '' | ||
| const allTests = Object.create(null) | ||
| let currentTest | ||
| let totalDuration = 0 | ||
|
|
||
| function lastTestInStack() { | ||
| return testStack.length ? testStack[testStack.length - 1] : null | ||
| } | ||
|
|
||
| function appendDiagnosticMessage(message) { | ||
| diagnosticMessage += `${message}\n` | ||
| function appendDiagnosticMessage(data) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reordered these when I was going to use lastTestInStack. Can put them back in the previous order if this is confusing. |
||
| // currentTest is for diagnostics after all tests are complete | ||
| // which do not have a file, line, or column. | ||
| const t = allTests[testId(data)] || currentTest | ||
| if (!t.diagnostic) { | ||
| t.diagnostic = '' | ||
| } | ||
| t.diagnostic += `${data.message}\n` | ||
| } | ||
|
|
||
| function resetDiagnosticMessage() { | ||
| diagnosticMessage = '' | ||
| function testId(data) { | ||
| return [data.file, data.line, data.column].join('\0') | ||
| } | ||
|
|
||
| function isFileUrl(urlString) { | ||
|
|
@@ -52,13 +58,13 @@ export default async function parseReport(source) { | |
| data: { name, file } | ||
| } = event | ||
|
|
||
| resetDiagnosticMessage() | ||
|
|
||
| testStack.push({ | ||
| const t = { | ||
| name, | ||
| file: parseFilePath(file), | ||
| tests: [] | ||
| }) | ||
| } | ||
| allTests[testId(event.data)] = t | ||
| testStack.push(t) | ||
|
|
||
| break | ||
|
|
||
|
|
@@ -72,7 +78,7 @@ export default async function parseReport(source) { | |
| } | ||
| } = event | ||
|
|
||
| const currentTest = testStack.pop() | ||
| currentTest = testStack.pop() | ||
| currentTest.duration = duration | ||
| currentTest.skip = skip !== undefined | ||
| currentTest.todo = todo !== undefined | ||
|
|
@@ -89,10 +95,6 @@ export default async function parseReport(source) { | |
| } | ||
| } | ||
|
|
||
| if (diagnosticMessage) { | ||
| currentTest.diagnostic = diagnosticMessage | ||
| } | ||
|
|
||
| if (lastTestInStack()) { | ||
| lastTestInStack().tests.push(currentTest) | ||
| } else { | ||
|
|
@@ -111,7 +113,7 @@ export default async function parseReport(source) { | |
| totalDuration = parseFloat(durationMatch[1]) | ||
| } | ||
|
|
||
| appendDiagnosticMessage(message) | ||
| appendDiagnosticMessage(event.data) | ||
|
|
||
| break | ||
| } | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
This is a little bit of a hack to hold on to the last test, so that messages that come in without file, line, and column have somewhere to go.