fix(test runner): trim full output path (#12239)

Previously, we only trimmed the "full title" component, but
we should also trim the "relative path" component.
This commit is contained in:
Dmitry Gozman 2022-02-18 15:40:36 -08:00 committed by GitHub
parent a7ef1da5e9
commit ee0dd6ec71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -117,7 +117,7 @@ export class TestInfoImpl implements TestInfo {
const sanitizedRelativePath = relativeTestFilePath.replace(process.platform === 'win32' ? new RegExp('\\\\', 'g') : new RegExp('/', 'g'), '-');
const fullTitleWithoutSpec = test.titlePath().slice(1).join(' ') + (test._type === 'test' ? '' : '-worker' + this.workerIndex);
let testOutputDir = sanitizedRelativePath + '-' + sanitizeForFilePath(trimLongString(fullTitleWithoutSpec));
let testOutputDir = trimLongString(sanitizedRelativePath + '-' + sanitizeForFilePath(fullTitleWithoutSpec));
if (uniqueProjectNamePathSegment)
testOutputDir += '-' + sanitizeForFilePath(uniqueProjectNamePathSegment);
if (this.retry)

View File

@ -431,7 +431,7 @@ test('should allow nonAscii characters in the output dir', async ({ runInlineTes
test('should allow shorten long output dirs characters in the output dir', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
'my-test.spec.js': `
'very/deep/and/long/file/name/that/i/want/to/be/trimmed/my-test.spec.js': `
const { test } = pwt;
test.describe('this is a really long description that would be too long for a file path', () => {
test('and this is an even longer test name that just keeps going and going and we should shorten it', async ({}, testInfo) => {
@ -441,7 +441,7 @@ test('should allow shorten long output dirs characters in the output dir', async
`,
});
const outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-this-is-a-really-long-description-that-would-b-6d724--keeps-going-and-going-and-we-should-shorten-it'));
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'very-deep-and-long-file-name-that-i-want-to-be-99202--keeps-going-and-going-and-we-should-shorten-it'));
});
test('should not mangle double dashes', async ({ runInlineTest }, testInfo) => {