Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/playwright/src/isomorphic/testServerInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface TestServerInterface {
closeOnDisconnect?: boolean,
interceptStdio?: boolean,
watchTestDirs?: boolean,
populateDependenciesOnList?: boolean,
}): Promise<void>;

ping(params: {}): Promise<void>;
Expand Down
6 changes: 1 addition & 5 deletions packages/playwright/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
* limitations under the License.
*/

import type { FullConfig, Suite } from '../../types/testReporter';
import type { FullConfig } from '../../types/testReporter';
import type { ReporterV2 } from '../reporters/reporterV2';

export interface TestRunnerPlugin {
name: string;
setup?(config: FullConfig, configDir: string, reporter: ReporterV2): Promise<void>;
populateDependencies?(): Promise<void>;
clearCache?(): Promise<void>;
begin?(suite: Suite): Promise<void>;
end?(): Promise<void>;
teardown?(): Promise<void>;
}

Expand Down
23 changes: 1 addition & 22 deletions packages/playwright/src/runner/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { createTitleMatcher, forceRegExp, removeDirAndLogToConsole } from '../ut

import type { TestGroup } from '../runner/testGroups';
import type { EnvByProjectId } from './dispatcher';
import type { TestRunnerPluginRegistration } from '../plugins';
import type { Task } from './taskRunner';
import type { FullResult, TestError } from '../../types/testReporter';
import type { Matcher, TestCaseFilter } from '../util';
Expand Down Expand Up @@ -164,7 +163,6 @@ export function createRunTestsTasks(config: FullConfigInternal) {
return [
createPhasesTask(),
createReportBeginTask(),
...config.plugins.map(plugin => createPluginBeginTask(plugin)),
createRunTestsTask(),
];
}
Expand All @@ -174,8 +172,6 @@ export function createClearCacheTask(config: FullConfigInternal): Task<TestRun>
title: 'clear cache',
setup: async () => {
await removeDirAndLogToConsole(cc.cacheDir);
for (const plugin of config.plugins)
await plugin.instance?.clearCache?.();
},
};
}
Expand Down Expand Up @@ -206,18 +202,6 @@ export function createPluginSetupTasks(config: FullConfigInternal): Task<TestRun
}));
}

function createPluginBeginTask(plugin: TestRunnerPluginRegistration): Task<TestRun> {
return {
title: 'plugin begin',
setup: async testRun => {
await plugin.instance?.begin?.(testRun.rootSuite!);
},
teardown: async () => {
await plugin.instance?.end?.();
},
};
}

function createGlobalSetupTask(file: string, config: FullConfigInternal): Task<TestRun> {
let title = 'global setup';
if (config.globalSetups.length > 1)
Expand Down Expand Up @@ -300,7 +284,7 @@ export function createListFilesTask(): Task<TestRun> {
};
}

export function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filterOnly: boolean, failOnLoadErrors: boolean, doNotRunDepsOutsideProjectFilter?: boolean, populateDependencies?: boolean }): Task<TestRun> {
export function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filterOnly: boolean, failOnLoadErrors: boolean, doNotRunDepsOutsideProjectFilter?: boolean }): Task<TestRun> {
return {
title: 'load tests',
setup: async (testRun, errors, softErrors) => {
Expand Down Expand Up @@ -342,11 +326,6 @@ export function createLoadTask(mode: 'out-of-process' | 'in-process', options: {
await collectProjectsAndTestFiles(testRun, !!options.doNotRunDepsOutsideProjectFilter);
await loadFileSuites(testRun, mode, options.failOnLoadErrors ? errors : softErrors);

if (testRun.options.onlyChanged || options.populateDependencies) {
for (const plugin of testRun.config.plugins)
await plugin.instance?.populateDependencies?.();
}

if (testRun.options.onlyChanged) {
const changedFiles = await detectChangedTestFiles(testRun.options.onlyChanged, testRun.config.configDir);
testRun.preOnlyTestFilters.push(test => changedFiles.has(test.location.file));
Expand Down
8 changes: 2 additions & 6 deletions packages/playwright/src/runner/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
private _globalSetup: { cleanup: () => Promise<any> } | undefined;
private _plugins: TestRunnerPluginRegistration[] | undefined;
private _watchTestDirs = false;
private _populateDependenciesOnList = false;
private _startingEnv: NodeJS.ProcessEnv = {};
private _lastLoadedConfig: FullConfigInternal | undefined;

Expand All @@ -117,11 +116,9 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {

async initialize(params: {
watchTestDirs?: boolean;
populateDependenciesOnList?: boolean;
}) {
setPlaywrightTestProcessEnv();
this._watchTestDirs = !!params.watchTestDirs;
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
this._startingEnv = { ...process.env };
}

Expand Down Expand Up @@ -195,7 +192,6 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
if (!config)
return { status: 'failed' };
const status = await runTasks(new TestRun(config, reporter), [
...createPluginSetupTasks(config),
createClearCacheTask(config),
]);
return { status };
Expand Down Expand Up @@ -251,7 +247,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
};

const status = await runTasks(new TestRun(config, reporter, options), [
createLoadTask('out-of-process', { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
createLoadTask('out-of-process', { failOnLoadErrors: false, filterOnly: false }),
createReportBeginTask(),
]);
return { config, status };
Expand Down Expand Up @@ -360,7 +356,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
return { errors: errorReporter.errors(), testFiles: [] };
const status = await runTasks(new TestRun(config, reporter), [
...createPluginSetupTasks(config),
createLoadTask('out-of-process', { failOnLoadErrors: true, filterOnly: false, populateDependencies: true }),
createLoadTask('out-of-process', { failOnLoadErrors: true, filterOnly: false }),
]);
if (status !== 'passed')
return { errors: errorReporter.errors(), testFiles: [] };
Expand Down
1 change: 0 additions & 1 deletion packages/playwright/src/runner/watchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
await testServerConnection.initialize({
interceptStdio: false,
watchTestDirs: true,
populateDependenciesOnList: true,
});
await testServerConnection.runGlobalSetup({});

Expand Down
35 changes: 1 addition & 34 deletions packages/playwright/src/transform/compilationCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type SerializedCompilationCache = {
sourceMaps: [string, string][],
memoryCache: [string, MemoryCache][],
fileDependencies: [string, string[]][],
externalDependencies: [string, string[]][],
};

// Assumptions for the compilation cache:
Expand Down Expand Up @@ -64,8 +63,6 @@ const sourceMaps: Map<string, string> = new Map();
const memoryCache = new Map<string, MemoryCache>();
// Dependencies resolved by the loader.
const fileDependencies = new Map<string, Set<string>>();
// Dependencies resolved by the external bundler.
const externalDependencies = new Map<string, Set<string>>();

export function installSourceMapSupport() {
Error.stackTraceLimit = 200;
Expand Down Expand Up @@ -174,7 +171,6 @@ export function serializeCompilationCache(): SerializedCompilationCache {
sourceMaps: [...sourceMaps.entries()],
memoryCache: [...memoryCache.entries()],
fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => ([filename, [...deps]])),
externalDependencies: [...externalDependencies.entries()].map(([filename, deps]) => ([filename, [...deps]])),
};
}

Expand All @@ -187,10 +183,6 @@ export function addToCompilationCache(payload: SerializedCompilationCache) {
const existing = fileDependencies.get(entry[0]) || [];
fileDependencies.set(entry[0], new Set([...entry[1], ...existing]));
}
for (const entry of payload.externalDependencies) {
const existing = externalDependencies.get(entry[0]) || [];
externalDependencies.set(entry[0], new Set([...entry[1], ...existing]));
}
}

function calculateFilePathHash(filePath: string): string {
Expand Down Expand Up @@ -237,11 +229,6 @@ export function currentFileDepsCollector(): Set<string> | undefined {
return depsCollector;
}

export function setExternalDependencies(filename: string, deps: string[]) {
const depsSet = new Set(deps.filter(dep => !belongsToNodeModules(dep) && dep !== filename));
externalDependencies.set(filename, depsSet);
}

export function fileDependenciesForTest() {
return Object.fromEntries([...fileDependencies.entries()].map(entry => (
[path.basename(entry[0]), [...entry[1]].map(f => path.basename(f)).sort()]
Expand All @@ -258,18 +245,6 @@ export function collectAffectedTestFiles(changedFile: string, testFileCollector:
if (deps.has(changedFile))
testFileCollector.add(testFile);
}

for (const [importingFile, depsOfImportingFile] of externalDependencies) {
if (depsOfImportingFile.has(changedFile)) {
if (isTestFile(importingFile))
testFileCollector.add(importingFile);

for (const [testFile, depsOfTestFile] of fileDependencies) {
if (depsOfTestFile.has(importingFile))
testFileCollector.add(testFile);
}
}
}
}

export function affectedTestFiles(changes: string[]): string[] {
Expand All @@ -284,15 +259,7 @@ export function internalDependenciesForTestFile(filename: string): Set<string> |
}

export function dependenciesForTestFile(filename: string): Set<string> {
const result = new Set<string>();
for (const testDependency of fileDependencies.get(filename) || []) {
result.add(testDependency);
for (const externalDependency of externalDependencies.get(testDependency) || [])
result.add(externalDependency);
}
for (const dep of externalDependencies.get(filename) || [])
result.add(dep);
return result;
return fileDependencies.get(filename) || new Set();
}

// This is only used in the dev mode, specifically excluding
Expand Down
Loading