Skip to content

Commit

Permalink
Fix EOL issues - remove all \r from annotation message
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Jan 14, 2021
1 parent 4197e7a commit 760c090
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
2 changes: 0 additions & 2 deletions __tests__/__snapshots__/dotnet-trx.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ Object {
"annotation_level": "failure",
"end_line": 27,
"message": "Assert.Equal() Failure
Expected: 3
Actual: 2",
"path": "DotnetTests.XUnitTests/CalculatorTests.cs",
"start_line": 27,
Expand Down
13 changes: 9 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/parsers/dart-json/dart-json-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Annotation, ParseOptions, TestResult} from '../parser-types'

import getReport from '../../report/get-report'
import {normalizeFilePath} from '../../utils/file-utils'
import {Icon} from '../../utils/markdown-utils'
import {Icon, fixEol} from '../../utils/markdown-utils'

import {
ReportEvent,
Expand Down Expand Up @@ -176,7 +176,7 @@ function getAnnotation(
start_line: src.line,
end_line: src.line,
path: src.file,
message: `${test.error?.error}\n\n${test.error?.stackTrace}`,
message: `${fixEol(test.error?.error)}\n\n${fixEol(test.error?.stackTrace)}`,
title: `[${testSuite.suite.path}] ${test.testStart.test.name}`
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/dotnet-trx/dotnet-trx-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {parseStringPromise} from 'xml2js'

import {normalizeFilePath} from '../../utils/file-utils'
import {parseAttribute} from '../../utils/xml-utils'
import {Icon} from '../../utils/markdown-utils'
import {Icon, fixEol} from '../../utils/markdown-utils'

import {
TestExecutionResult,
Expand Down Expand Up @@ -123,7 +123,7 @@ function getAnnotations(testClasses: TestClass[], workDir: string, trackedFiles:
start_line: src.line,
end_line: src.line,
path: src.file,
message: t.error.Message[0],
message: fixEol(t.error.Message[0]),
title: `[${tc.name}] ${t.name}`
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/jest-junit/jest-junit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Annotation, ParseOptions, TestResult} from '../parser-types'
import {parseStringPromise} from 'xml2js'

import {JunitReport, TestCase, TestSuite} from './jest-junit-types'
import {Icon} from '../../utils/markdown-utils'
import {fixEol, Icon} from '../../utils/markdown-utils'
import {normalizeFilePath} from '../../utils/file-utils'
import {parseAttribute} from '../../utils/xml-utils'

Expand Down Expand Up @@ -91,7 +91,7 @@ function getAnnotations(junit: JunitReport, workDir: string, trackedFiles: strin
start_line: src.line,
end_line: src.line,
path: src.file,
message: ex,
message: fixEol(ex),
title: `[${suite.$.name}] ${tc.$.name.trim()}`
})
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/markdown-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ export function table(headers: ToString[], align: ToString[], ...rows: ToString[
export function tableEscape(content: ToString): string {
return content.toString().replace('|', '\\|')
}

export function fixEol(text?: string): string {
return text?.replace(/\r/g, '') ?? ''
}

0 comments on commit 760c090

Please sign in to comment.