chore: hide reporter project id (#17710)

This commit is contained in:
Pavel Feldman 2022-09-29 11:51:06 -08:00 committed by GitHub
parent b4ee84fb0c
commit a97deb1600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 29 deletions

View file

@ -150,13 +150,6 @@ Filter to only run tests with a title **not** matching one of the patterns. This
`grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests). `grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests).
## property: TestProject.id
* since: v1.27
- type: ?<[string]>
Unique project id within this config.
## property: TestProject.metadata ## property: TestProject.metadata
* since: v1.10 * since: v1.10
- type: ?<[Metadata]> - type: ?<[Metadata]>

View file

@ -178,7 +178,7 @@ export class Loader {
const candidate = name + (i ? i : ''); const candidate = name + (i ? i : '');
if (usedNames.has(candidate)) if (usedNames.has(candidate))
continue; continue;
p.id = candidate; p._id = candidate;
usedNames.add(candidate); usedNames.add(candidate);
break; break;
} }
@ -290,7 +290,7 @@ export class Loader {
process.env.PWTEST_USE_SCREENSHOTS_DIR = '1'; process.env.PWTEST_USE_SCREENSHOTS_DIR = '1';
} }
return { return {
id: '', _id: '',
_fullConfig: fullConfig, _fullConfig: fullConfig,
_fullyParallel: takeFirst(projectConfig.fullyParallel, config.fullyParallel, undefined), _fullyParallel: takeFirst(projectConfig.fullyParallel, config.fullyParallel, undefined),
_expect: takeFirst(projectConfig.expect, config.expect, {}), _expect: takeFirst(projectConfig.expect, config.expect, {}),
@ -402,20 +402,20 @@ class ProjectSuiteBuilder {
test.retries = this._project.retries; test.retries = this._project.retries;
const repeatEachIndexSuffix = repeatEachIndex ? ` (repeat:${repeatEachIndex})` : ''; const repeatEachIndexSuffix = repeatEachIndex ? ` (repeat:${repeatEachIndex})` : '';
// At the point of the query, suite is not yet attached to the project, so we only get file, describe and test titles. // At the point of the query, suite is not yet attached to the project, so we only get file, describe and test titles.
const testIdExpression = `[project=${this._project.id}]${test.titlePath().join('\x1e')}${repeatEachIndexSuffix}`; const testIdExpression = `[project=${this._project._id}]${test.titlePath().join('\x1e')}${repeatEachIndexSuffix}`;
const testId = to._fileId + '-' + calculateSha1(testIdExpression).slice(0, 20); const testId = to._fileId + '-' + calculateSha1(testIdExpression).slice(0, 20);
test.id = testId; test.id = testId;
test.repeatEachIndex = repeatEachIndex; test.repeatEachIndex = repeatEachIndex;
test._projectId = this._project.id; test._projectId = this._project._id;
if (!filter(test)) { if (!filter(test)) {
to._entries.pop(); to._entries.pop();
to.tests.pop(); to.tests.pop();
} else { } else {
const pool = this._buildPool(entry); const pool = this._buildPool(entry);
if (this._project._fullConfig._workerIsolation === 'isolate-pools') if (this._project._fullConfig._workerIsolation === 'isolate-pools')
test._workerHash = `run${this._project.id}-${pool.digest}-repeat${repeatEachIndex}`; test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
else else
test._workerHash = `run${this._project.id}-repeat${repeatEachIndex}`; test._workerHash = `run${this._project._id}-repeat${repeatEachIndex}`;
test._pool = pool; test._pool = pool;
} }
} }
@ -447,7 +447,7 @@ class ProjectSuiteBuilder {
(originalFixtures as any)[key] = value; (originalFixtures as any)[key] = value;
} }
if (Object.entries(optionsFromConfig).length) if (Object.entries(optionsFromConfig).length)
result.push({ fixtures: optionsFromConfig, location: { file: `project#${this._project.id}`, line: 1, column: 1 } }); result.push({ fixtures: optionsFromConfig, location: { file: `project#${this._project._id}`, line: 1, column: 1 } });
if (Object.entries(originalFixtures).length) if (Object.entries(originalFixtures).length)
result.push({ fixtures: originalFixtures, location: f.location }); result.push({ fixtures: originalFixtures, location: f.location });
} }

View file

@ -63,7 +63,7 @@ class JSONReporter implements Reporter {
repeatEach: project.repeatEach, repeatEach: project.repeatEach,
retries: project.retries, retries: project.retries,
metadata: project.metadata, metadata: project.metadata,
id: project.id, id: (project as any)._id,
name: project.name, name: project.name,
testDir: toPosixPath(project.testDir), testDir: toPosixPath(project.testDir),
testIgnore: serializePatterns(project.testIgnore), testIgnore: serializePatterns(project.testIgnore),
@ -80,7 +80,7 @@ class JSONReporter implements Reporter {
private _mergeSuites(suites: Suite[]): JSONReportSuite[] { private _mergeSuites(suites: Suite[]): JSONReportSuite[] {
const fileSuites = new MultiMap<string, JSONReportSuite>(); const fileSuites = new MultiMap<string, JSONReportSuite>();
for (const projectSuite of suites) { for (const projectSuite of suites) {
const projectId = projectSuite.project()!.id; const projectId = (projectSuite.project() as any)._id;
const projectName = projectSuite.project()!.name; const projectName = projectSuite.project()!.name;
for (const fileSuite of projectSuite.suites) { for (const fileSuite of projectSuite.suites) {
const file = fileSuite.location!.file; const file = fileSuite.location!.file;

View file

@ -115,8 +115,8 @@ export class TestInfoImpl implements TestInfo {
const fullTitleWithoutSpec = test.titlePath().slice(1).join(' '); const fullTitleWithoutSpec = test.titlePath().slice(1).join(' ');
let testOutputDir = trimLongString(sanitizedRelativePath + '-' + sanitizeForFilePath(fullTitleWithoutSpec)); let testOutputDir = trimLongString(sanitizedRelativePath + '-' + sanitizeForFilePath(fullTitleWithoutSpec));
if (project.id) if (project._id)
testOutputDir += '-' + sanitizeForFilePath(project.id); testOutputDir += '-' + sanitizeForFilePath(project._id);
if (this.retry) if (this.retry)
testOutputDir += '-retry' + this.retry; testOutputDir += '-retry' + this.retry;
if (this.repeatEachIndex) if (this.repeatEachIndex)

View file

@ -70,6 +70,7 @@ export interface FullConfigInternal extends FullConfigPublic {
* increasing the surface area of the public API type called FullProject. * increasing the surface area of the public API type called FullProject.
*/ */
export interface FullProjectInternal extends FullProjectPublic { export interface FullProjectInternal extends FullProjectPublic {
_id: string;
_fullConfig: FullConfigInternal; _fullConfig: FullConfigInternal;
_fullyParallel: boolean; _fullyParallel: boolean;
_expect: Project['expect']; _expect: Project['expect'];

View file

@ -160,7 +160,7 @@ export class WorkerRunner extends EventEmitter {
return; return;
this._loader = await Loader.deserialize(this._params.loader); this._loader = await Loader.deserialize(this._params.loader);
this._project = this._loader.fullConfig().projects.find(p => p.id === this._params.projectId)!; this._project = this._loader.fullConfig().projects.find(p => p._id === this._params.projectId)!;
} }
async runTestGroup(runPayload: RunPayload) { async runTestGroup(runPayload: RunPayload) {

View file

@ -198,10 +198,6 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
* Metadata that will be put directly to the test report serialized as JSON. * Metadata that will be put directly to the test report serialized as JSON.
*/ */
metadata: Metadata; metadata: Metadata;
/**
* Unique project id within this config.
*/
id: string;
/** /**
* Project name is visible in the report and during test execution. * Project name is visible in the report and during test execution.
*/ */
@ -4434,11 +4430,6 @@ interface TestProject {
*/ */
grepInvert?: RegExp|Array<RegExp>; grepInvert?: RegExp|Array<RegExp>;
/**
* Unique project id within this config.
*/
id?: string;
/** /**
* Metadata that will be put directly to the test report serialized as JSON. * Metadata that will be put directly to the test report serialized as JSON.
*/ */

View file

@ -41,7 +41,6 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
grep: RegExp | RegExp[]; grep: RegExp | RegExp[];
grepInvert: RegExp | RegExp[] | null; grepInvert: RegExp | RegExp[] | null;
metadata: Metadata; metadata: Metadata;
id: string;
name: string; name: string;
snapshotDir: string; snapshotDir: string;
outputDir: string; outputDir: string;