Merge branch 'dorny:main'

This commit is contained in:
Ray Xu 2024-03-03 14:06:44 -08:00
commit 0b7d35fd12
46 changed files with 35637 additions and 15914 deletions

View file

@ -0,0 +1,16 @@
![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
<details><summary>Expand for details</summary>
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/jest/jest-react-component-test-results.xml|1:white_check_mark:|||1000ms|
## :white_check_mark: <a id="user-content-r0" href="#r0">fixtures/external/jest/jest-react-component-test-results.xml</a>
**1** tests were completed in **1000ms** with **1** passed, **0** failed and **0** skipped.
|Test suite|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|[\<Component /\>](#r0s0)|1:white_check_mark:|||798ms|
### :white_check_mark: <a id="user-content-r0s0" href="#r0s0">\<Component /\></a>
```
:white_check_mark: <Component /> should render properly
```
</details>

View file

@ -0,0 +1,16 @@
![Tests failed](https://img.shields.io/badge/tests-2%20passed%2C%201%20failed-critical)
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/swift-xunit.xml|2:white_check_mark:|1:x:||220ms|
## :x: <a id="user-content-r0" href="#r0">fixtures/swift-xunit.xml</a>
**3** tests were completed in **220ms** with **2** passed, **1** failed and **0** skipped.
|Test suite|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|[TestResults](#r0s0)|2:white_check_mark:|1:x:||220ms|
### :x: <a id="user-content-r0s0" href="#r0s0">TestResults</a>
```
AcmeLibTests.AcmeLibTests
:white_check_mark: test_always_pass
:white_check_mark: test_always_skip
:x: test_always_fail
```

View file

@ -3,12 +3,12 @@
exports[`dart-json tests matches report snapshot 1`] = `
TestRunResult {
"path": "fixtures/dart-json.json",
"suites": Array [
"suites": [
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "Test 1",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "Passing test",
@ -19,11 +19,11 @@ TestRunResult {
},
TestGroupResult {
"name": "Test 1 Test 1.1",
"tests": Array [
"tests": [
TestCaseResult {
"error": Object {
"error": {
"details": "package:test_api expect
test\\\\main_test.dart 13:9 main.<fn>.<fn>.<fn>
test\\main_test.dart 13:9 main.<fn>.<fn>.<fn>
",
"line": 13,
"message": "Expected: <2>
@ -36,9 +36,9 @@ test\\\\main_test.dart 13:9 main.<fn>.<fn>.<fn>
"time": 20,
},
TestCaseResult {
"error": Object {
"error": {
"details": "package:darttest/main.dart 2:3 throwError
test\\\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
test\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
",
"line": 17,
"message": "Exception: Some error",
@ -52,10 +52,10 @@ test\\\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
},
TestGroupResult {
"name": "Test 2",
"tests": Array [
"tests": [
TestCaseResult {
"error": Object {
"details": "test\\\\main_test.dart 24:7 main.<fn>.<fn>
"error": {
"details": "test\\main_test.dart 24:7 main.<fn>.<fn>
",
"line": 24,
"message": "Exception: Some error",
@ -72,12 +72,12 @@ test\\\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": null,
"tests": Array [
"tests": [
TestCaseResult {
"error": Object {
"error": {
"details": "dart:isolate _RawReceivePortImpl._handleMessage
",
"line": 5,
@ -108,12 +108,12 @@ test\\\\main_test.dart 17:9 main.<fn>.<fn>.<fn>
exports[`dart-json tests report from rrousselGit/provider test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/external/flutter/provider-test-results.json",
"suites": Array [
"suites": [
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "valueListenableProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "rebuilds when value change",
@ -139,7 +139,7 @@ TestRunResult {
"time": 22,
},
TestCaseResult {
"error": Object {
"error": {
"details": "══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
Expected: <2>
@ -178,10 +178,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "ListenableProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "works with MultiProvider",
@ -252,7 +252,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ListenableProvider value constructor",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "pass down key",
@ -269,7 +269,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ListenableProvider stateful constructor",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "called with context",
@ -295,10 +295,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "consumer",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -321,7 +321,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "consumer2",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -344,7 +344,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "consumer3",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -367,7 +367,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "consumer4",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -390,7 +390,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "consumer5",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -413,7 +413,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "consumer6",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "obtains value from Provider<T>",
@ -439,10 +439,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "Use builder property, not child",
@ -453,7 +453,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ChangeNotifierProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "value",
@ -515,10 +515,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "ChangeNotifierProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "default",
@ -535,7 +535,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ListenableProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "default",
@ -552,7 +552,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "Provider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "default",
@ -569,7 +569,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ProxyProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "0",
@ -616,7 +616,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "MultiProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "with 1 ChangeNotifierProvider default",
@ -690,10 +690,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "MultiProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "throw if providers is null",
@ -719,10 +719,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "works with MultiProvider",
@ -763,7 +763,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "StreamProvider()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "create and dispose stream with builder",
@ -783,10 +783,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "watch in layoutbuilder",
@ -827,7 +827,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "BuildContext",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "internal selected value is updated",
@ -985,10 +985,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "ReassembleHandler",
@ -1014,10 +1014,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "works with MultiProvider",
@ -1076,7 +1076,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "FutureProvider()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "crashes if builder is null",
@ -1090,10 +1090,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "works with MultiProvider",
@ -1104,7 +1104,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "Provider.of",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "throws if T is dynamic",
@ -1139,7 +1139,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "Provider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "throws if the provided value is a Listenable/Stream",
@ -1177,10 +1177,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "regression test #377",
@ -1371,7 +1371,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "diagnostics",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "InheritedProvider.value",
@ -1406,7 +1406,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "InheritedProvider.value()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "markNeedsNotifyDependents during startListening is noop",
@ -1459,7 +1459,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "InheritedProvider()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "hasValue",
@ -1614,7 +1614,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "DeferredInheritedProvider.value()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "hasValue",
@ -1667,7 +1667,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "DeferredInheritedProvider()",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "create can't call inherited widgets",
@ -1699,10 +1699,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "ListenableProxyProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "throws if update is missing",
@ -1743,7 +1743,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ListenableProxyProvider variants",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "ListenableProxyProvider",
@ -1787,10 +1787,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "asserts that builder/selector are not null",
@ -1900,10 +1900,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "asserts",
@ -1935,10 +1935,10 @@ Unexpected number of calls
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
"groups": [
TestGroupResult {
"name": "ProxyProvider",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "throws if the provided value is a Listenable/Stream",
@ -2009,7 +2009,7 @@ Unexpected number of calls
},
TestGroupResult {
"name": "ProxyProvider variants",
"tests": Array [
"tests": [
TestCaseResult {
"error": undefined,
"name": "ProxyProvider2",

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`swift-xunit tests report from swift test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/swift-xunit.xml",
"suites": [
TestSuiteResult {
"groups": [
TestGroupResult {
"name": "AcmeLibTests.AcmeLibTests",
"tests": [
TestCaseResult {
"error": undefined,
"name": "test_always_pass",
"result": "success",
"time": 36.386333,
},
TestCaseResult {
"error": undefined,
"name": "test_always_skip",
"result": "success",
"time": 92.039167,
},
TestCaseResult {
"error": {
"details": undefined,
"line": undefined,
"message": undefined,
"path": undefined,
},
"name": "test_always_fail",
"result": "failed",
"time": 92.05175,
},
],
},
],
"name": "TestResults",
"totalTime": 220.47725000000003,
},
],
"totalTime": undefined,
}
`;

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="0" failures="0" errors="0" time="11.299">
<testsuite name="__tests__\main.test.js" errors="0" failures="0" skipped="0" timestamp="2020-10-27T21:39:41" time="0.486" tests="0">
</testsuite>
</testsuites>

View file

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='utf-8'?>
<testsuites name="my_package.test_foo" tests="3" failures="1" errors="0" time="6.79"><testsuite name="my_package.test_foo.launch_tests" tests="3" failures="1" errors="0" skipped="0" time="6.79"><testcase classname="my_package.TestFoo" name="test_normal_case" time="2.172" /><testcase classname="my_package.TestFoo" name="test_other_case" time="4.558"><failure message="Traceback (most recent call last):&#10; File &quot;/home/redacted/test_foo.py&quot;, line 183, in test_other_case&#10; self.assertFalse(True)&#10;AssertionError: True is not false&#10;" /></testcase><testcase classname="my_package.TestFoo" name="test_yet_another_case" time="0.06" /></testsuite></testsuites>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="React components test" tests="1" failures="0" errors="0" time="1.0">
<testsuite name="&lt;Component /&gt;" errors="0" failures="0" skipped="0" timestamp="2021-01-24T19:21:45" time="0.798" tests="1">
<testcase classname="" name="&lt;Component /&gt; should render properly" time="0.704">
</testcase>
</testsuite>
</testsuites>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="TestResults" errors="0" tests="3" failures="1" time="0.22047725">
<testcase classname="AcmeLibTests.AcmeLibTests" name="test_always_pass" time="0.036386333">
</testcase>
<testcase classname="AcmeLibTests.AcmeLibTests" name="test_always_skip" time="0.092039167">
</testcase>
<testcase classname="AcmeLibTests.AcmeLibTests" name="test_always_fail" time="0.09205175">
<failure message="failed"></failure>
</testcase>
</testsuite>
</testsuites>

View file

@ -72,4 +72,22 @@ describe('java-junit tests', () => {
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
it('parses empty failures in test results', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'empty_failures.xml')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const trackedFiles: string[] = []
const opts: ParseOptions = {
parseErrors: true,
trackedFiles
}
const parser = new JavaJunitParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result.result === 'failed')
expect(result.failed === 1)
})
})

View file

@ -0,0 +1,75 @@
import {parseStackTraceElement} from '../src/parsers/java-junit/java-stack-trace-element-parser'
describe('parseStackTraceLine tests', () => {
it('empty line is not parsed', async () => {
const line = ''
expect(parseStackTraceElement(line)).toBe(undefined)
})
describe('java class', () => {
it('simple', async () => {
const line =
'at org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings(AddMissingPatchVersionTest.java:29)'
expect(parseStackTraceElement(line)).toEqual({
tracePath: 'org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings',
fileName: 'AddMissingPatchVersionTest.java',
lineStr: '29'
})
})
it('inner class', async () => {
const line = 'at com.foo.Main$Inner.run(Main.java:29)'
expect(parseStackTraceElement(line)).toEqual({
tracePath: 'com.foo.Main$Inner.run',
fileName: 'Main.java',
lineStr: '29'
})
})
it('starts with whitespaces', async () => {
const line =
' \tat org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings(AddMissingPatchVersionTest.java:29)'
expect(parseStackTraceElement(line)).toEqual({
tracePath: 'org.apache.pulsar.AddMissingPatchVersionTest.testVersionStrings',
fileName: 'AddMissingPatchVersionTest.java',
lineStr: '29'
})
})
describe('since Java 9', () => {
it('with classloader and module', async () => {
// Based on Java 9 StackTraceElement.toString() Doc: https://docs.oracle.com/javase/9/docs/api/java/lang/StackTraceElement.html#toString--
const line = 'at com.foo.loader/foo@9.0/com.foo.Main.run(Main.java:101)'
expect(parseStackTraceElement(line)).toEqual({
classLoader: 'com.foo.loader',
moduleNameAndVersion: 'foo@9.0',
tracePath: 'com.foo.Main.run',
fileName: 'Main.java',
lineStr: '101'
})
})
it('with classloader', async () => {
const line = 'at com.foo.loader//com.foo.Main.run(Main.java:101)'
expect(parseStackTraceElement(line)).toEqual({
classLoader: 'com.foo.loader',
moduleNameAndVersion: undefined,
tracePath: 'com.foo.Main.run',
fileName: 'Main.java',
lineStr: '101'
})
})
})
})
describe('Kotlin class', () => {
it('method name containing whitespaces', async () => {
const line = 'at com.foo.Main.method with whitespaces(Main.kt:18)'
expect(parseStackTraceElement(line)).toEqual({
tracePath: 'com.foo.Main.method with whitespaces',
fileName: 'Main.kt',
lineStr: '18'
})
})
})
})

View file

@ -7,7 +7,7 @@ import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
describe('jest-junit tests', () => {
it('produces empty test run result when there are no test cases', async () => {
it('produces empty test run result when there are no test cases in the testsuites element', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit.xml')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
@ -23,6 +23,22 @@ describe('jest-junit tests', () => {
expect(result.result).toBe('success')
})
it('produces empty test run result when there are no test cases in a nested testsuite element', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit-empty-testsuite.xml')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: []
}
const parser = new JestJunitParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result.tests).toBe(0)
expect(result.result).toBe('success')
})
it('report from ./reports/jest test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
@ -66,4 +82,27 @@ describe('jest-junit tests', () => {
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
it('report from #235 testing react components named <ComponentName />', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'jest', 'jest-react-component-test-results.xml')
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
const outputPath = path.join(__dirname, '__outputs__', 'jest-react-component-test-results.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
const opts: ParseOptions = {
parseErrors: true,
trackedFiles
//workDir: '/home/dorny/dorny/jest/'
}
const parser = new JestJunitParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
})

View file

@ -0,0 +1,30 @@
import * as fs from 'fs'
import * as path from 'path'
import {SwiftXunitParser} from '../src/parsers/swift-xunit/swift-xunit-parser'
import {ParseOptions} from '../src/test-parser'
import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
describe('swift-xunit tests', () => {
it('report from swift test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'swift-xunit.xml')
const outputPath = path.join(__dirname, '__outputs__', 'swift-xunit.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const trackedFiles = ['Package.swift', 'Sources/AcmeLib/AcmeLib.swift', 'Tests/AcmeLibTests/AcmeLibTests.swift']
const opts: ParseOptions = {
parseErrors: true,
trackedFiles
}
const parser = new SwiftXunitParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
})