queue up dirtyTestFiles
This commit is contained in:
parent
74f095904b
commit
e53c5c6e6a
|
|
@ -26,7 +26,6 @@ import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer';
|
||||||
import { TestServerDispatcher } from './testServer';
|
import { TestServerDispatcher } from './testServer';
|
||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import { type TestServerTransport, TestServerConnection } from '../isomorphic/testServerConnection';
|
import { type TestServerTransport, TestServerConnection } from '../isomorphic/testServerConnection';
|
||||||
import { createFileMatcherFromArguments } from '../util';
|
|
||||||
import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater';
|
import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater';
|
||||||
|
|
||||||
class InMemoryTransport extends EventEmitter implements TestServerTransport {
|
class InMemoryTransport extends EventEmitter implements TestServerTransport {
|
||||||
|
|
@ -95,24 +94,31 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
const dirtyTestFiles = new Set<string>();
|
const dirtyTestFiles = new Set<string>();
|
||||||
const onDirtyTestFiles: { resolve?(): void } = {};
|
const onDirtyTestFiles: { resolve?(): void } = {};
|
||||||
|
|
||||||
testServerConnection.onTestFilesChanged(async ({ testFiles: changedFiles }) => {
|
let queue = Promise.resolve();
|
||||||
|
|
||||||
|
testServerConnection.onTestFilesChanged(({ testFiles: changedFiles }) => {
|
||||||
if (changedFiles.length === 0)
|
if (changedFiles.length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
queue = queue.then(async () => {
|
||||||
teleSuiteUpdater.processListReport(report);
|
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
||||||
|
teleSuiteUpdater.processListReport(report);
|
||||||
|
|
||||||
for (const project of teleSuiteUpdater.rootSuite!.suites) {
|
for (const project of teleSuiteUpdater.rootSuite!.suites) {
|
||||||
for (const suite of project.suites) {
|
for (const suite of project.suites) {
|
||||||
if (suite.location?.file && changedFiles.includes(suite.location.file))
|
if (suite.location?.file && changedFiles.includes(suite.location.file))
|
||||||
dirtyTestFiles.add(suite.location.file);
|
dirtyTestFiles.add(suite.location.file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (dirtyTestFiles.size === 0)
|
// if listTests takes longer than the debouncing interval of onTestFilesChanged,
|
||||||
return;
|
// then the queue might contain another listTests call.
|
||||||
|
// appending `resolve` to the queue ensures that all pending listTests calls are executed first.
|
||||||
onDirtyTestFiles.resolve?.();
|
queue = queue.then(() => {
|
||||||
|
if (dirtyTestFiles.size > 0)
|
||||||
|
onDirtyTestFiles.resolve?.();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report));
|
testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue