From 574868ab61f8d462c036e9e00e3dce8a693d23fd Mon Sep 17 00:00:00 2001 From: Ray Xu Date: Wed, 29 May 2024 16:58:25 -0700 Subject: [PATCH] Undo trx parsing changes temporarily --- __tests__/__outputs__/dotnet-trx.md | 4 ++-- .../__outputs__/fluent-validation-test-results.md | 4 ++-- __tests__/__outputs__/silent-notes-test-results.md | 4 ++-- __tests__/__snapshots__/dotnet-trx.test.ts.snap | 6 +++--- dist/index.js | 11 ++--------- src/parsers/dotnet-trx/dotnet-trx-parser.ts | 14 ++------------ src/parsers/dotnet-trx/dotnet-trx-types.ts | 1 - 7 files changed, 13 insertions(+), 31 deletions(-) diff --git a/__tests__/__outputs__/dotnet-trx.md b/__tests__/__outputs__/dotnet-trx.md index c4ca1a9..9b3ef03 100644 --- a/__tests__/__outputs__/dotnet-trx.md +++ b/__tests__/__outputs__/dotnet-trx.md @@ -1,8 +1,8 @@ ![Tests failed](https://img.shields.io/badge/tests-5%20passed%2C%205%20failed%2C%201%20skipped-critical) |Report|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| -|DotnetTests.XUnitTests|5:white_check_mark:|5:x:|1:warning:|1s| -## :x: DotnetTests.XUnitTests +|fixtures/dotnet-trx.trx|5:white_check_mark:|5:x:|1:warning:|1s| +## :x: fixtures/dotnet-trx.trx **11** tests were completed in **1s** with **5** passed, **5** failed and **1** skipped. |Test suite|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| diff --git a/__tests__/__outputs__/fluent-validation-test-results.md b/__tests__/__outputs__/fluent-validation-test-results.md index f2aed19..0df62fd 100644 --- a/__tests__/__outputs__/fluent-validation-test-results.md +++ b/__tests__/__outputs__/fluent-validation-test-results.md @@ -3,8 +3,8 @@ |Report|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| -|FluentValidation.Tests|803:white_check_mark:||1:warning:|4s| -## :white_check_mark: FluentValidation.Tests +|fixtures/external/FluentValidation.Tests.trx|803:white_check_mark:||1:warning:|4s| +## :white_check_mark: fixtures/external/FluentValidation.Tests.trx **804** tests were completed in **4s** with **803** passed, **0** failed and **1** skipped. |Test suite|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| diff --git a/__tests__/__outputs__/silent-notes-test-results.md b/__tests__/__outputs__/silent-notes-test-results.md index e76c0dd..7c27e31 100644 --- a/__tests__/__outputs__/silent-notes-test-results.md +++ b/__tests__/__outputs__/silent-notes-test-results.md @@ -3,8 +3,8 @@ |Report|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| -|VanillaCloudStorageClientTest|67:white_check_mark:||12:warning:|1s| -## :white_check_mark: VanillaCloudStorageClientTest +|fixtures/external/SilentNotes.trx|67:white_check_mark:||12:warning:|1s| +## :white_check_mark: fixtures/external/SilentNotes.trx **79** tests were completed in **1s** with **67** passed, **0** failed and **12** skipped. |Test suite|Passed|Failed|Skipped|Time| |:---|---:|---:|---:|---:| diff --git a/__tests__/__snapshots__/dotnet-trx.test.ts.snap b/__tests__/__snapshots__/dotnet-trx.test.ts.snap index 4244109..1ca07eb 100644 --- a/__tests__/__snapshots__/dotnet-trx.test.ts.snap +++ b/__tests__/__snapshots__/dotnet-trx.test.ts.snap @@ -2,7 +2,7 @@ exports[`dotnet-trx tests matches report snapshot 1`] = ` TestRunResult { - "path": "DotnetTests.XUnitTests", + "path": "fixtures/dotnet-trx.trx", "suites": [ TestSuiteResult { "groups": [ @@ -131,7 +131,7 @@ Actual: False", exports[`dotnet-trx tests report from FluentValidation test results matches snapshot 1`] = ` TestRunResult { - "path": "FluentValidation.Tests", + "path": "fixtures/external/FluentValidation.Tests.trx", "suites": [ TestSuiteResult { "groups": [ @@ -5646,7 +5646,7 @@ TestRunResult { exports[`dotnet-trx tests report from SilentNotes test results matches snapshot 1`] = ` TestRunResult { - "path": "VanillaCloudStorageClientTest", + "path": "fixtures/external/SilentNotes.trx", "suites": [ TestSuiteResult { "groups": [ diff --git a/dist/index.js b/dist/index.js index 795c10b..4178503 100644 --- a/dist/index.js +++ b/dist/index.js @@ -751,9 +751,8 @@ const path_utils_1 = __nccwpck_require__(4070); const parse_utils_1 = __nccwpck_require__(7811); const test_results_1 = __nccwpck_require__(2768); class TestClass { - constructor(name, assemblyName) { + constructor(name) { this.name = name; - this.assemblyName = assemblyName; this.tests = []; } } @@ -815,12 +814,9 @@ class DotnetTrxParser { const testClasses = {}; for (const r of unitTestsResults) { const className = r.test.TestMethod[0].$.className; - const codeBase = r.test.TestMethod[0].$.codeBase; - const pathSegments = codeBase.replace(/\\/g, '/').split('/'); - const assemblyName = pathSegments[pathSegments.length - 1].replace('.dll', ''); let tc = testClasses[className]; if (tc === undefined) { - tc = new TestClass(className, assemblyName); + tc = new TestClass(className); testClasses[tc.name] = tc; } const error = this.getErrorInfo(r.result); @@ -847,9 +843,6 @@ class DotnetTrxParser { const group = new test_results_1.TestGroupResult(null, tests); return new test_results_1.TestSuiteResult(testClass.name, [group]); }); - if (testClasses.length > 0) { - return new test_results_1.TestRunResult(testClasses[0].assemblyName, suites, totalTime); - } return new test_results_1.TestRunResult(path, suites, totalTime); } getErrorInfo(testResult) { diff --git a/src/parsers/dotnet-trx/dotnet-trx-parser.ts b/src/parsers/dotnet-trx/dotnet-trx-parser.ts index 802b023..a81d4a2 100644 --- a/src/parsers/dotnet-trx/dotnet-trx-parser.ts +++ b/src/parsers/dotnet-trx/dotnet-trx-parser.ts @@ -16,10 +16,7 @@ import { } from '../../test-results' class TestClass { - constructor( - readonly name: string, - readonly assemblyName: string - ) {} + constructor(readonly name: string) {} readonly tests: Test[] = [] } @@ -84,12 +81,9 @@ export class DotnetTrxParser implements TestParser { const testClasses: {[name: string]: TestClass} = {} for (const r of unitTestsResults) { const className = r.test.TestMethod[0].$.className - const codeBase = r.test.TestMethod[0].$.codeBase - const pathSegments = codeBase.replace(/\\/g, '/').split('/') - const assemblyName = pathSegments[pathSegments.length - 1].replace('.dll', '') let tc = testClasses[className] if (tc === undefined) { - tc = new TestClass(className, assemblyName) + tc = new TestClass(className) testClasses[tc.name] = tc } const error = this.getErrorInfo(r.result) @@ -123,10 +117,6 @@ export class DotnetTrxParser implements TestParser { return new TestSuiteResult(testClass.name, [group]) }) - if (testClasses.length > 0) { - return new TestRunResult(testClasses[0].assemblyName, suites, totalTime) - } - return new TestRunResult(path, suites, totalTime) } diff --git a/src/parsers/dotnet-trx/dotnet-trx-types.ts b/src/parsers/dotnet-trx/dotnet-trx-types.ts index ddc6202..97dbf8a 100644 --- a/src/parsers/dotnet-trx/dotnet-trx-types.ts +++ b/src/parsers/dotnet-trx/dotnet-trx-types.ts @@ -30,7 +30,6 @@ export interface UnitTest { export interface TestMethod { $: { - codeBase: string className: string name: string }