one listTests at a time

This commit is contained in:
Simon Knott 2024-09-03 09:36:59 +02:00
parent b9173b05ef
commit b97bed5e31
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -98,28 +98,28 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
let onDirtyTests = new ManualPromise(); let onDirtyTests = new ManualPromise();
let queue = Promise.resolve(); let queue = Promise.resolve();
const changedFiles = new Set<string>();
testServerConnection.onTestFilesChanged(({ testFiles: changedFiles }) => { testServerConnection.onTestFilesChanged(({ testFiles }) => {
if (changedFiles.length === 0) testFiles.forEach(file => changedFiles.add(file));
return;
queue = queue.then(async () => { queue = queue.then(async () => {
if (changedFiles.size === 0)
return;
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);
for (const test of teleSuiteUpdater.rootSuite!.allTests()) { for (const test of teleSuiteUpdater.rootSuite!.allTests()) {
if (changedFiles.includes(test.location.file)) if (changedFiles.has(test.location.file))
dirtyTestIds.add(test.id); dirtyTestIds.add(test.id);
} }
// listTests can take longer than the debouncing interval of onTestFilesChanged, changedFiles.clear();
// so the queue might contain another set of changed files to be processed before executing tests.
queue = queue.then(() => {
if (dirtyTestIds.size > 0) if (dirtyTestIds.size > 0)
onDirtyTests.resolve?.(); onDirtyTests.resolve?.();
}); });
}); });
});
testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report)); testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report));
await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true }); await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true });