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 { EventEmitter } from 'stream';
|
||||
import { type TestServerTransport, TestServerConnection } from '../isomorphic/testServerConnection';
|
||||
import { createFileMatcherFromArguments } from '../util';
|
||||
import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater';
|
||||
|
||||
class InMemoryTransport extends EventEmitter implements TestServerTransport {
|
||||
|
|
@ -95,10 +94,13 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
|||
const dirtyTestFiles = new Set<string>();
|
||||
const onDirtyTestFiles: { resolve?(): void } = {};
|
||||
|
||||
testServerConnection.onTestFilesChanged(async ({ testFiles: changedFiles }) => {
|
||||
let queue = Promise.resolve();
|
||||
|
||||
testServerConnection.onTestFilesChanged(({ testFiles: changedFiles }) => {
|
||||
if (changedFiles.length === 0)
|
||||
return;
|
||||
|
||||
queue = queue.then(async () => {
|
||||
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
||||
teleSuiteUpdater.processListReport(report);
|
||||
|
||||
|
|
@ -109,11 +111,15 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
|||
}
|
||||
}
|
||||
|
||||
if (dirtyTestFiles.size === 0)
|
||||
return;
|
||||
|
||||
// if listTests takes longer than the debouncing interval of onTestFilesChanged,
|
||||
// then the queue might contain another listTests call.
|
||||
// appending `resolve` to the queue ensures that all pending listTests calls are executed first.
|
||||
queue = queue.then(() => {
|
||||
if (dirtyTestFiles.size > 0)
|
||||
onDirtyTestFiles.resolve?.();
|
||||
});
|
||||
});
|
||||
});
|
||||
testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report));
|
||||
|
||||
await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true });
|
||||
|
|
|
|||
Loading…
Reference in a new issue