fix(reporters): improve detection of output folder clashes (#30607)
When comparing `outputDir` and html-reporter `outputFolder`, we now make sure that both paths end with a forward-slash. Fixes #28677 --------- Co-authored-by: Georg Unterholzner <georg.unterholzner@dynatrace.com>
This commit is contained in:
parent
c1fbc753a7
commit
8173cdc485
|
|
@ -87,7 +87,7 @@ class HtmlReporter extends EmptyReporter {
|
||||||
this._attachmentsBaseURL = attachmentsBaseURL;
|
this._attachmentsBaseURL = attachmentsBaseURL;
|
||||||
const reportedWarnings = new Set<string>();
|
const reportedWarnings = new Set<string>();
|
||||||
for (const project of this.config.projects) {
|
for (const project of this.config.projects) {
|
||||||
if (outputFolder.startsWith(project.outputDir) || project.outputDir.startsWith(outputFolder)) {
|
if (this._isSubdirectory(outputFolder, project.outputDir) || this._isSubdirectory(project.outputDir, outputFolder)) {
|
||||||
const key = outputFolder + '|' + project.outputDir;
|
const key = outputFolder + '|' + project.outputDir;
|
||||||
if (reportedWarnings.has(key))
|
if (reportedWarnings.has(key))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -113,6 +113,11 @@ class HtmlReporter extends EmptyReporter {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isSubdirectory(parentDir: string, dir: string): boolean {
|
||||||
|
const relativePath = path.relative(parentDir, dir);
|
||||||
|
return !!relativePath && !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
override onError(error: TestError): void {
|
override onError(error: TestError): void {
|
||||||
this._topLevelErrors.push(error);
|
this._topLevelErrors.push(error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1094,6 +1094,26 @@ for (const useIntermediateMergeReport of [false] as const) {
|
||||||
expect(output).toContain('html-report');
|
expect(output).toContain('html-report');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it should only identify exact matches as clashing folders', async ({ runInlineTest, useIntermediateMergeReport }) => {
|
||||||
|
test.skip(useIntermediateMergeReport);
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = {
|
||||||
|
reporter: [['html', { outputFolder: 'test-results-html' }]]
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
'a.test.js': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('passes', async ({}) => {
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
const output = result.output;
|
||||||
|
expect(output).not.toContain('Configuration Error');
|
||||||
|
expect(output).toContain('test-results-html');
|
||||||
|
});
|
||||||
|
|
||||||
test.describe('report location', () => {
|
test.describe('report location', () => {
|
||||||
test('with config should create report relative to config', async ({ runInlineTest, useIntermediateMergeReport }, testInfo) => {
|
test('with config should create report relative to config', async ({ runInlineTest, useIntermediateMergeReport }, testInfo) => {
|
||||||
test.skip(useIntermediateMergeReport);
|
test.skip(useIntermediateMergeReport);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue