feat(test-runner): allow non-ascii characters in the output dir path (#8093)
This commit is contained in:
parent
78f24ec693
commit
64da74fba8
|
|
@ -215,3 +215,7 @@ export function expectType(receiver: any, type: string, matcherName: string) {
|
|||
if (typeof receiver !== 'object' || receiver.constructor.name !== type)
|
||||
throw new Error(`${matcherName} can be only used with ${type} object`);
|
||||
}
|
||||
|
||||
export function sanitizeForFilePath(s: string) {
|
||||
return s.replace(/[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import path from 'path';
|
|||
import rimraf from 'rimraf';
|
||||
import util from 'util';
|
||||
import { EventEmitter } from 'events';
|
||||
import { monotonicTime, DeadlineRunner, raceAgainstDeadline, serializeError } from './util';
|
||||
import { monotonicTime, DeadlineRunner, raceAgainstDeadline, serializeError, sanitizeForFilePath } from './util';
|
||||
import { TestBeginPayload, TestEndPayload, RunPayload, TestEntry, DonePayload, WorkerInitParams, StepBeginPayload, StepEndPayload } from './ipc';
|
||||
import { setCurrentTestInfo } from './globals';
|
||||
import { Loader } from './loader';
|
||||
|
|
@ -547,7 +547,3 @@ function modifier(testInfo: TestInfo, type: 'skip' | 'fail' | 'fixme' | 'slow',
|
|||
|
||||
class SkipError extends Error {
|
||||
}
|
||||
|
||||
function sanitizeForFilePath(s: string) {
|
||||
return s.replace(/[^\w\d]+/g, '-');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,3 +256,17 @@ test('should accept a relative path for outputDir', async ({ runInlineTest }, te
|
|||
}, {usesCustomOutputDir: true});
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
|
||||
test('should allow nonAscii characters in the output dir', async ({ runInlineTest }, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'my-test.spec.js': `
|
||||
const { test } = pwt;
|
||||
test('こんにちは世界', async ({}, testInfo) => {
|
||||
console.log('\\n%%' + testInfo.outputDir);
|
||||
});
|
||||
`,
|
||||
});
|
||||
const outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);
|
||||
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-こんにちは世界'));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue