perform premature optimisation

This commit is contained in:
Simon Knott 2024-07-22 14:26:08 +02:00
parent 338790f4af
commit 065f5ce7ec
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 4 additions and 4 deletions

View file

@ -235,7 +235,7 @@ function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filter
for (const plugin of testRun.config.plugins) for (const plugin of testRun.config.plugins)
await plugin.instance?.populateDependencies?.(); await plugin.instance?.populateDependencies?.();
const changedFiles = await detectChangedFiles(testRun.config.cliOnlyChanged); const changedFiles = await detectChangedFiles(testRun.config.cliOnlyChanged);
cliOnlyChangedMatcher = file => changedFiles.includes(file); cliOnlyChangedMatcher = file => changedFiles.has(file);
} }
testRun.rootSuite = await createRootSuite(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly, cliOnlyChangedMatcher); testRun.rootSuite = await createRootSuite(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly, cliOnlyChangedMatcher);

View file

@ -19,7 +19,7 @@ import { toPosixPath } from 'playwright-core/lib/utils';
import { affectedTestFiles } from '../transform/compilationCache'; import { affectedTestFiles } from '../transform/compilationCache';
import path from 'path'; import path from 'path';
export async function detectChangedFiles(baseCommit: string): Promise<string[]> { export async function detectChangedFiles(baseCommit: string): Promise<Set<string>> {
function gitFileList(command: string) { function gitFileList(command: string) {
try { try {
return childProcess.execSync( return childProcess.execSync(
@ -45,8 +45,8 @@ export async function detectChangedFiles(baseCommit: string): Promise<string[]>
const filesWithChanges = [...untrackedFiles, ...trackedFilesWithChanges]; const filesWithChanges = [...untrackedFiles, ...trackedFilesWithChanges];
const affectedFiles = affectedTestFiles(filesWithChanges); const affectedFiles = affectedTestFiles(filesWithChanges);
return [ return new Set([
...filesWithChanges, ...filesWithChanges,
...affectedFiles, ...affectedFiles,
].map(toPosixPath); ].map(toPosixPath));
} }