Skip to content

Commit

Permalink
- don't fail on skipped tests
Browse files Browse the repository at this point in the history
  - FIX #761
  • Loading branch information
mikepenz authored Jul 14, 2023
1 parent 6893ae6 commit bec5826
Show file tree
Hide file tree
Showing 7 changed files with 1,084 additions and 942 deletions.
1,925 changes: 1,022 additions & 903 deletions __tests__/testParser.test.ts

Large diffs are not rendered by default.

52 changes: 27 additions & 25 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import { parseFile, Transformer } from '../src/testParser';
import { readTransformers } from '../src/utils';
import {parseFile, Transformer} from '../src/testParser'
import {readTransformers} from '../src/utils'

/**
* Copyright 2022 Mike Penz
*/
jest.setTimeout(30000)

describe('readTransformers', () => {
it('should successfully parse default transformer', async () => {
const transformer = readTransformers('[{"searchValue":"::","replaceValue":"/"}]')
expect(transformer).toStrictEqual([
{
searchValue: "::",
replaceValue: "/",
}
]);
})
it('should successfully parse default transformer', async () => {
const transformer = readTransformers('[{"searchValue":"::","replaceValue":"/"}]')
expect(transformer).toStrictEqual([
{
searchValue: '::',
replaceValue: '/'
}
])
})

it('should successfully parse custom transformer', async () => {
const transformer = readTransformers('[{"searchValue":"\\\\.","replaceValue":"/"},{"searchValue":"_t\\\\z","replaceValue":".t"}]')
expect(transformer).toStrictEqual([
{
searchValue: "\\.",
replaceValue: "/",
},
{
searchValue: "_t\\z",
replaceValue: ".t",
},
]);
})
})
it('should successfully parse custom transformer', async () => {
const transformer = readTransformers(
'[{"searchValue":"\\\\.","replaceValue":"/"},{"searchValue":"_t\\\\z","replaceValue":".t"}]'
)
expect(transformer).toStrictEqual([
{
searchValue: '\\.',
replaceValue: '/'
},
{
searchValue: '_t\\z',
replaceValue: '.t'
}
])
})
})
17 changes: 11 additions & 6 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.

8 changes: 7 additions & 1 deletion src/annotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ export async function attachSummary(
detailsTable.push([
`${testResult.checkName}`,
`${annotation.title}`,
`${annotation.status === 'success' ? '✅ pass' : annotation.status === 'skipped' ? `⏭️ skipped` : `❌ ${annotation.annotation_level}`}`
`${
annotation.status === 'success'
? '✅ pass'
: annotation.status === 'skipped'
? `⏭️ skipped`
: `❌ ${annotation.annotation_level}`
}`
])
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ async function parseSuite(
for (const testcase of testcases) {
totalCount++

const failed = testcase.failure || testcase.error
const success = !failed
const skip = testcase.skipped || testcase._attributes.status === 'disabled'
const testFailure = testcase.failure || testcase.error // test failed
const skip =
testcase.skipped || testcase._attributes.status === 'disabled' || testcase._attributes.status === 'ignored'
const failed = testFailure && !skip // test faiure, but was skipped -> don't fail if a ignored test failed
const success = !testFailure // not a failure -> thus a success

// in some definitions `failure` may be an array
const failures = testcase.failure
Expand Down Expand Up @@ -366,7 +368,7 @@ async function parseSuite(
end_line: pos.line,
start_column: 0,
end_column: 0,
annotation_level: success ? 'notice' : 'failure',
annotation_level: success || skip ? 'notice' : 'failure', // a skipped test shall not fail the run
status: skip ? 'skipped' : success ? 'success' : 'failure',
title: escapeEmoji(title),
message: escapeEmoji(message),
Expand Down Expand Up @@ -401,9 +403,9 @@ export async function parseTestReports(
excludeSources: string[],
checkTitleTemplate: string | undefined = undefined,
testFilesPrefix = '',
transformer: Transformer[],
transformer: Transformer[] = [],
followSymlink = false,
annotationsLimit: number
annotationsLimit: number = -1

Check failure on line 408 in src/testParser.ts

View workflow job for this annotation

GitHub Actions / build

Type number trivially inferred from a number literal, remove type annotation
): Promise<TestResult> {
core.debug(`Process test report for: ${reportPaths} (${checkName})`)
const globber = await glob.create(reportPaths, {followSymbolicLinks: followSymlink})
Expand Down
8 changes: 8 additions & 0 deletions test_results/issues/testFailedDisabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name='random suite'>
<testcase classname="MiscTests - OS X" name="testSmemArithmetic" status="disabled">
<failure type="Test Failure">Assert: Boolean true check failed.</failure>
</testcase>
</testsuite>
</testsuites>

0 comments on commit bec5826

Please sign in to comment.