Skip to content

Commit

Permalink
Fix xml parsing issues for nested multiline string nodes (#293)
Browse files Browse the repository at this point in the history
fixes #292
  • Loading branch information
NasAmin authored Aug 20, 2023
1 parent 6daa816 commit 818ff78
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 407 deletions.
17 changes: 16 additions & 1 deletion __tests__/markup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ describe('When generating markup for trx', () => {
expect(testData).toContain(data.TrxData.TestRun.Times._start)
expect(testData).toContain(data.TrxData.TestRun.Times._finish)

// console.log(testData)
expect(testData).toContain(
data.TrxData.TestRun.Results.UnitTestResult[1].Output?.ErrorInfo?.Message
)

expect(
data.TrxData.TestRun.Results.UnitTestResult[1].Output?.ErrorInfo?.Message
).toEqual(`Assert.False() Failure
Expected: False
Actual: True`)

expect(
data.TrxData.TestRun.Results.UnitTestResult[1].Output?.ErrorInfo
?.StackTrace
).toEqual(
'at dummy_tests.DummyTest1.TestMethod4() in /root/UnitTest1.cs:line 30'
)
})

test('LoadXml For single test()', async () => {
Expand Down
380 changes: 7 additions & 373 deletions dist/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions dist/licenses.txt

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

12 changes: 5 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import * as core from '@actions/core'
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as fs from 'fs'
import * as he from 'he'
import * as path from 'path'
import * as uitl from 'util'
import {XMLParser, XMLValidator} from 'fast-xml-parser'
Expand Down Expand Up @@ -45,23 +44,22 @@ export async function transformTrxToJson(
const xmlData = await readTrxFile(filePath)
const options = {
attributeNamePrefix: '_',
// attrNodeName: 'attr', //default is 'false'
// attrNodeName: '@', //default is 'false'
textNodeName: '#text',
ignoreAttributes: false,
ignoreNameSpace: false,
allowBooleanAttributes: true,
parseNodeValue: true,
parseAttributeValue: true,
trimValues: true,
format: true,
indentBy: ' ',
supressEmptyNode: false,
rootNodeName: 'element',
cdataTagName: '__cdata', //default is 'false'
cdataPositionChar: '\\c',
parseTrueNumberOnly: false,
arrayMode: false, //"strict"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
attrValueProcessor: (val: string, _attrName: string) =>
he.decode(val, {isAttributeValue: true}), //default is a=>a
// eslint-disable-next-line @typescript-eslint/no-unused-vars
tagValueProcessor: (val: string, _tagName: string) => he.decode(val), //default is a=>a
stopNodes: ['parse-me-as-string']
}

Expand Down
4 changes: 3 additions & 1 deletion test-data/failing-tests/dummy-tests.trx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<UnitTestResult executionId="311ef751-a4cd-4b8f-b035-a80a60a0d356" testId="4bf72103-4551-c34e-0c54-c20c09328bff" testName="TestMethod4" computerName="staging-tests-vr4mc" duration="00:00:00.0136651" startTime="2020-10-09T12:16:32.8054653+00:00" endTime="2020-10-09T12:16:32.8194691+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="311ef751-a4cd-4b8f-b035-a80a60a0d356">
<Output>
<ErrorInfo>
<Message>Assert.IsTrue failed. </Message>
<Message>Assert.False() Failure
Expected: False
Actual: True</Message>
<StackTrace> at dummy_tests.DummyTest1.TestMethod4() in /root/UnitTest1.cs:line 30
</StackTrace>
</ErrorInfo>
Expand Down

0 comments on commit 818ff78

Please sign in to comment.