only return test files

This commit is contained in:
Simon Knott 2024-07-23 16:54:57 +02:00
parent 961cafc28e
commit acdde570aa
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 4 additions and 10 deletions

View file

@ -31,7 +31,7 @@ import type { Matcher } from '../util';
import { Suite } from '../common/test';
import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils';
import { FailureTracker } from './failureTracker';
import { detectChangedFiles } from './vcs';
import { detectChangedTests } from './vcs';
const readDirAsync = promisify(fs.readdir);
@ -234,7 +234,7 @@ function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filter
if (testRun.config.cliOnlyChanged && options.filterOnlyChanged) {
for (const plugin of testRun.config.plugins)
await plugin.instance?.populateDependencies?.();
const changedFiles = await detectChangedFiles(testRun.config.cliOnlyChanged, testRun.config.configDir);
const changedFiles = await detectChangedTests(testRun.config.cliOnlyChanged, testRun.config.configDir);
cliOnlyChangedMatcher = file => changedFiles.has(file);
}

View file

@ -18,7 +18,7 @@ import childProcess from 'child_process';
import { affectedTestFiles } from '../transform/compilationCache';
import path from 'path';
export async function detectChangedFiles(baseCommit: string, configDir: string): Promise<Set<string>> {
export async function detectChangedTests(baseCommit: string, configDir: string): Promise<Set<string>> {
function gitFileList(command: string) {
try {
return childProcess.execSync(
@ -41,11 +41,5 @@ export async function detectChangedFiles(baseCommit: string, configDir: string):
const [gitRoot] = gitFileList('rev-parse --show-toplevel');
const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`).map(file => path.join(gitRoot, file));
const filesWithChanges = [...untrackedFiles, ...trackedFilesWithChanges];
const affectedFiles = affectedTestFiles(filesWithChanges);
return new Set([
...filesWithChanges,
...affectedFiles,
]);
return new Set(affectedTestFiles([...untrackedFiles, ...trackedFilesWithChanges]));
}