address the easy ones
This commit is contained in:
parent
a10649b72e
commit
a327f8979c
|
|
@ -136,7 +136,7 @@ export class Runner {
|
||||||
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
|
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
|
||||||
return await runWatchModeLoop(
|
return await runWatchModeLoop(
|
||||||
{ configDir: config.configDir, resolvedConfigFile: config.config.configFile },
|
{ configDir: config.configDir, resolvedConfigFile: config.config.configFile },
|
||||||
{ projects: config.cliProjectFilter, files: config.cliArgs, grep: config.cliGrep, onlyChanged: config.cliOnlyChanged }
|
{ projects: config.cliProjectFilter, files: config.cliArgs, grep: config.cliGrep }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ class InMemoryTransport extends EventEmitter implements TestServerTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
onerror(listener: () => void): void {
|
onerror(listener: () => void): void {
|
||||||
|
// no-op to fulfil the interface, the user of InMemoryTransport doesn't emit any errors.
|
||||||
this.on('error', listener);
|
this.on('error', listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +67,6 @@ interface WatchModeOptions {
|
||||||
files?: string[];
|
files?: string[];
|
||||||
projects?: string[];
|
projects?: string[];
|
||||||
grep?: string;
|
grep?: string;
|
||||||
onlyChanged?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runWatchModeLoop(configLocation: ConfigLocation, initialOptions: WatchModeOptions): Promise<FullResult['status']> {
|
export async function runWatchModeLoop(configLocation: ConfigLocation, initialOptions: WatchModeOptions): Promise<FullResult['status']> {
|
||||||
|
|
@ -90,7 +90,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
const testServerConnection = new TestServerConnection(transport);
|
const testServerConnection = new TestServerConnection(transport);
|
||||||
transport.emit('open');
|
transport.emit('open');
|
||||||
|
|
||||||
const telesuiteUpdater = new TeleSuiteUpdater({ pathSeparator: path.sep, onUpdate() { } });
|
const teleSuiteUpdater = new TeleSuiteUpdater({ pathSeparator: path.sep, onUpdate() { } });
|
||||||
|
|
||||||
const dirtyTestFiles = new Set<string>();
|
const dirtyTestFiles = new Set<string>();
|
||||||
const onDirtyTestFiles: { resolve?(): void } = {};
|
const onDirtyTestFiles: { resolve?(): void } = {};
|
||||||
|
|
@ -100,9 +100,9 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
return;
|
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 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);
|
||||||
|
|
@ -114,13 +114,13 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
|
|
||||||
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 });
|
||||||
await testServerConnection.runGlobalSetup({});
|
await testServerConnection.runGlobalSetup({});
|
||||||
|
|
||||||
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[], dirtyTestFiles?: string[] } = { type: 'regular' };
|
||||||
let result: FullResult['status'] = 'passed';
|
let result: FullResult['status'] = 'passed';
|
||||||
|
|
@ -160,7 +160,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
type: 'multiselect',
|
type: 'multiselect',
|
||||||
name: 'selectedProjects',
|
name: 'selectedProjects',
|
||||||
message: 'Select projects',
|
message: 'Select projects',
|
||||||
choices: telesuiteUpdater.rootSuite!.suites.map(s => s.title),
|
choices: teleSuiteUpdater.rootSuite!.suites.map(s => s.title),
|
||||||
}).catch(() => ({ selectedProjects: null }));
|
}).catch(() => ({ selectedProjects: null }));
|
||||||
if (!selectedProjects)
|
if (!selectedProjects)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -205,7 +205,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command === 'failed') {
|
if (command === 'failed') {
|
||||||
const failedTestIds = telesuiteUpdater.rootSuite!.allTests().filter(t => !t.ok()).map(t => t.id);
|
const failedTestIds = teleSuiteUpdater.rootSuite!.allTests().filter(t => !t.ok()).map(t => t.id);
|
||||||
await runTests({}, testServerConnection, { title: 'running failed tests', testIds: failedTestIds });
|
await runTests({}, testServerConnection, { title: 'running failed tests', testIds: failedTestIds });
|
||||||
lastRun = { type: 'failed', failedTestIds };
|
lastRun = { type: 'failed', failedTestIds };
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -340,8 +340,6 @@ function printConfiguration(options: WatchModeOptions, title?: string) {
|
||||||
tokens.push(...options.projects.map(p => colors.blue(`--project ${p}`)));
|
tokens.push(...options.projects.map(p => colors.blue(`--project ${p}`)));
|
||||||
if (options.grep)
|
if (options.grep)
|
||||||
tokens.push(colors.red(`--grep ${options.grep}`));
|
tokens.push(colors.red(`--grep ${options.grep}`));
|
||||||
if (options.onlyChanged)
|
|
||||||
tokens.push(colors.yellow(`--only-changed ${options.onlyChanged}`));
|
|
||||||
if (options.files)
|
if (options.files)
|
||||||
tokens.push(...options.files.map(a => colors.bold(a)));
|
tokens.push(...options.files.map(a => colors.bold(a)));
|
||||||
if (title)
|
if (title)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue