Add option to convert backslashes in path pattern to forward slashes

The fast-glob library that is internally used interprets backslashes as escape characters. If enabled, all backslashes in provided path will be replaced by forward slashes and act as directory separators. It might be useful when path input variable is composed dynamically from existing directory paths on Windows.

Closes #127
This commit is contained in:
Michal Dorner 2021-06-22 22:33:11 +02:00
parent ad831af420
commit de0b4b9ece
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
6 changed files with 43 additions and 22 deletions

View file

@ -16,7 +16,7 @@ import {JavaJunitParser} from './parsers/java-junit/java-junit-parser'
import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser'
import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser'
import {normalizeDirPath} from './utils/path-utils'
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
import {getCheckRunContext} from './utils/github-utils'
import {Icon} from './utils/markdown-utils'
@ -33,6 +33,7 @@ class TestReporter {
readonly artifact = core.getInput('artifact', {required: false})
readonly name = core.getInput('name', {required: true})
readonly path = core.getInput('path', {required: true})
readonly pathReplaceBackslashes = core.getInput('path-replace-backslashes', {required: false}) === 'true'
readonly reporter = core.getInput('reporter', {required: true})
readonly listSuites = core.getInput('list-suites', {required: true}) as 'all' | 'failed'
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
@ -71,7 +72,11 @@ class TestReporter {
core.info(`Check runs will be created with SHA=${this.context.sha}`)
const pattern = this.path.split(',')
// Split path pattern by ',' and optionally convert all backslashes to forward slashes
// fast-glob (micromatch) always interprets backslashes as escape characters instead of directory separators
const pathsList = this.path.split(',')
const pattern = this.pathReplaceBackslashes ? pathsList.map(normalizeFilePath) : pathsList
const inputProvider = this.artifact
? new ArtifactProvider(
this.octokit,