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,10 +94,13 @@ 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;
|
||||||
|
|
||||||
|
queue = queue.then(async () => {
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -109,11 +111,15 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
queue = queue.then(() => {
|
||||||
|
if (dirtyTestFiles.size > 0)
|
||||||
onDirtyTestFiles.resolve?.();
|
onDirtyTestFiles.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 });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue