Skip to content

Commit

Permalink
fix singular testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
atlowChemi committed Feb 28, 2023
1 parent e5e65f7 commit c7fd487
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13646,6 +13646,9 @@ function escapeEmoji(input) {
const regex = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/gu;
return input.replace(regex, ``);
}
function castArray(value) {
return Array.isArray(value) ? value : [value];
}
function findMatchingOption(message, ...strings) {
for (const str2 of strings) {
const index2 = message.indexOf(str2);
Expand Down Expand Up @@ -13722,8 +13725,9 @@ async function parseSuite(report, fileName, projectTokenDictionaryStrs) {
if (!(testsuite == null ? void 0 : testsuite.testcase)) {
return result;
}
const testListInfo = await getTestStatusesFromPublicAPI(testsuite.testcase, projectTokenDictionaryStrs);
for (const { failure, skipped, name, ["system-out"]: systemOut, classname } of testsuite.testcase) {
const testCases = castArray(testsuite.testcase);
const testListInfo = await getTestStatusesFromPublicAPI(testCases, projectTokenDictionaryStrs);
for (const { failure, skipped, name, ["system-out"]: systemOut, classname } of testCases) {
result.totalCount++;
const success = !failure;
if (typeof skipped !== "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/junitParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as core from '@actions/core';
import * as glob from '@actions/glob';
import * as github from '@actions/github';
import { XMLParser } from 'fast-xml-parser';
import { escapeEmoji, retrieve, parseTestimFailureMessage, getTestStatusesFromPublicAPI } from './utils';
import { escapeEmoji, retrieve, castArray, parseTestimFailureMessage, getTestStatusesFromPublicAPI } from './utils';
import type { parseInputs } from './inputParser';

interface InternalTestResult {
Expand Down Expand Up @@ -57,7 +57,7 @@ interface JUnitSuite {
skipped: string;
tests: string;
timestamp: string;
testcase: JUnitTestCase[];
testcase: JUnitTestCase | JUnitTestCase[];
}
interface JUnitReport {
testsuite?: JUnitSuite;
Expand All @@ -81,9 +81,10 @@ async function parseSuite(report: JUnitReport, fileName: string, projectTokenDic
return result;
}

const testListInfo = await getTestStatusesFromPublicAPI(testsuite.testcase, projectTokenDictionaryStrs);
const testCases = castArray(testsuite.testcase);
const testListInfo = await getTestStatusesFromPublicAPI(testCases, projectTokenDictionaryStrs);

for (const { failure, skipped, name, ['system-out']: systemOut, classname } of testsuite.testcase) {
for (const { failure, skipped, name, ['system-out']: systemOut, classname } of testCases) {
result.totalCount++;
const success = !failure;

Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export function escapeEmoji(input: string) {
return input.replace(regex, ``);
}

export function castArray<T>(value: T | T[]) {
return Array.isArray(value) ? value : [value];
}

function findMatchingOption(message: string, ...strings: string[]) {
for (const str of strings) {
const index = message.indexOf(str);
Expand Down

0 comments on commit c7fd487

Please sign in to comment.