mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
feat: consider tracked files to get absolute paths
This commit is contained in:
parent
0d3dd791da
commit
33125699e3
3 changed files with 23 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ describe('pytest-junit tests', () => {
|
||||||
const opts: ParseOptions = {
|
const opts: ParseOptions = {
|
||||||
parseErrors: true,
|
parseErrors: true,
|
||||||
workDir: 'mnt/extra-addons',
|
workDir: 'mnt/extra-addons',
|
||||||
trackedFiles: ['mnt/extra-addons/product_changes/tests/first_test.py']
|
trackedFiles: ['addons/product_changes/tests/first_test.py']
|
||||||
}
|
}
|
||||||
|
|
||||||
const parser = new PytestJunitParser(opts)
|
const parser = new PytestJunitParser(opts)
|
||||||
|
|
@ -45,6 +45,6 @@ describe('pytest-junit tests', () => {
|
||||||
|
|
||||||
const annotations = getAnnotations([result], 1)
|
const annotations = getAnnotations([result], 1)
|
||||||
expect(annotations.length).toBe(1)
|
expect(annotations.length).toBe(1)
|
||||||
expect(annotations[0].path).toBe('product_changes/tests/first_test.py')
|
expect(annotations[0].path).toBe('addons/product_changes/tests/first_test.py')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
11
dist/index.js
generated
vendored
11
dist/index.js
generated
vendored
|
|
@ -1494,7 +1494,7 @@ class PytestJunitParser {
|
||||||
const line = Number.parseInt(pos);
|
const line = Number.parseInt(pos);
|
||||||
if (path && Number.isFinite(line)) {
|
if (path && Number.isFinite(line)) {
|
||||||
return {
|
return {
|
||||||
path: this.getRelativePath(path),
|
path: this.getAbsolutePath(path),
|
||||||
line,
|
line,
|
||||||
message: lines[1]
|
message: lines[1]
|
||||||
};
|
};
|
||||||
|
|
@ -1509,6 +1509,15 @@ class PytestJunitParser {
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
getAbsolutePath(path) {
|
||||||
|
const relativePath = this.getRelativePath(path);
|
||||||
|
for (const file of this.options.trackedFiles) {
|
||||||
|
if (file.endsWith(relativePath)) {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return relativePath;
|
||||||
|
}
|
||||||
getWorkDir(path) {
|
getWorkDir(path) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
|
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ export class PytestJunitParser implements TestParser {
|
||||||
|
|
||||||
if (path && Number.isFinite(line)) {
|
if (path && Number.isFinite(line)) {
|
||||||
return {
|
return {
|
||||||
path: this.getRelativePath(path),
|
path: this.getAbsolutePath(path),
|
||||||
line,
|
line,
|
||||||
message: lines[1]
|
message: lines[1]
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +121,16 @@ export class PytestJunitParser implements TestParser {
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getAbsolutePath(path: string): string {
|
||||||
|
const relativePath = this.getRelativePath(path)
|
||||||
|
for (const file of this.options.trackedFiles) {
|
||||||
|
if (file.endsWith(relativePath)) {
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return relativePath
|
||||||
|
}
|
||||||
|
|
||||||
private getWorkDir(path: string): string | undefined {
|
private getWorkDir(path: string): string | undefined {
|
||||||
return (
|
return (
|
||||||
this.options.workDir ??
|
this.options.workDir ??
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue