remove runChangedTests in favor of testID filtering simplicity
This commit is contained in:
parent
a327f8979c
commit
4fb58c85d3
|
|
@ -122,7 +122,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
||||||
teleSuiteUpdater.processListReport(report);
|
teleSuiteUpdater.processListReport(report);
|
||||||
|
|
||||||
let lastRun: { type: 'changed' | 'regular' | 'failed', failedTestIds?: string[], dirtyTestFiles?: string[] } = { type: 'regular' };
|
let lastRun: { type: 'changed' | 'regular' | 'failed', failedTestIds?: string[], dirtyTestIds?: string[] } = { type: 'regular' };
|
||||||
let result: FullResult['status'] = 'passed';
|
let result: FullResult['status'] = 'passed';
|
||||||
|
|
||||||
// Enter the watch loop.
|
// Enter the watch loop.
|
||||||
|
|
@ -141,10 +141,10 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
const command = await readCommandPromise;
|
const command = await readCommandPromise;
|
||||||
|
|
||||||
if (command === 'changed') {
|
if (command === 'changed') {
|
||||||
const changedFiles = [...dirtyTestFiles];
|
const testIds = teleSuiteUpdater.rootSuite!.allTests().filter(t => dirtyTestFiles.has(t.location.file)).map(t => t.id);
|
||||||
dirtyTestFiles.clear();
|
dirtyTestFiles.clear();
|
||||||
await runChangedTests(options, testServerConnection, changedFiles);
|
await runTests(options, testServerConnection, { testIds, title: 'files changed' });
|
||||||
lastRun = { type: 'changed', dirtyTestFiles: changedFiles };
|
lastRun = { type: 'changed', dirtyTestIds: testIds };
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +216,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
await runTests(options, testServerConnection, { title: 're-running tests' });
|
await runTests(options, testServerConnection, { title: 're-running tests' });
|
||||||
continue;
|
continue;
|
||||||
} else if (lastRun.type === 'changed') {
|
} else if (lastRun.type === 'changed') {
|
||||||
await runChangedTests(options, testServerConnection, lastRun.dirtyTestFiles!, 're-running tests');
|
await runTests(options, testServerConnection, { title: 're-running tests', testIds: lastRun.dirtyTestIds });
|
||||||
} else if (lastRun.type === 'failed') {
|
} else if (lastRun.type === 'failed') {
|
||||||
await runTests({}, testServerConnection, { title: 're-running tests', testIds: [...lastRun.failedTestIds!] });
|
await runTests({}, testServerConnection, { title: 're-running tests', testIds: [...lastRun.failedTestIds!] });
|
||||||
}
|
}
|
||||||
|
|
@ -242,25 +242,16 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
return result === 'passed' ? teardown.status : result;
|
return result === 'passed' ? teardown.status : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function runChangedTests(watchOptions: WatchModeOptions, testServerConnection: TestServerConnection, changedFiles: string[], title?: string) {
|
|
||||||
if (watchOptions.files?.length)
|
|
||||||
changedFiles = changedFiles.filter(createFileMatcherFromArguments(watchOptions.files));
|
|
||||||
|
|
||||||
await runTests(watchOptions, testServerConnection, { title: title || 'files changed', locations: changedFiles });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runTests(watchOptions: WatchModeOptions, testServerConnection: TestServerConnection, options?: {
|
async function runTests(watchOptions: WatchModeOptions, testServerConnection: TestServerConnection, options?: {
|
||||||
title?: string,
|
title?: string,
|
||||||
testIds?: string[],
|
testIds?: string[],
|
||||||
locations?: string[],
|
|
||||||
}) {
|
}) {
|
||||||
printConfiguration(watchOptions, options?.title);
|
printConfiguration(watchOptions, options?.title);
|
||||||
|
|
||||||
await testServerConnection.runTests({
|
await testServerConnection.runTests({
|
||||||
grep: watchOptions.grep,
|
grep: watchOptions.grep,
|
||||||
testIds: options?.testIds,
|
testIds: options?.testIds,
|
||||||
locations: options?.locations ?? watchOptions?.files,
|
locations: watchOptions?.files,
|
||||||
projects: watchOptions.projects,
|
projects: watchOptions.projects,
|
||||||
connectWsEndpoint,
|
connectWsEndpoint,
|
||||||
reuseContext: connectWsEndpoint ? true : undefined,
|
reuseContext: connectWsEndpoint ? true : undefined,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue