Skip to content

Commit

Permalink
remove unnecessary return value on adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Jan 14, 2025
1 parent d36304e commit 026d0b4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/client/testing/testController/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ export interface ITestResultResolver {
}
export interface ITestDiscoveryAdapter {
// ** first line old method signature, second line new method signature
discoverTests(uri: Uri): Promise<DiscoveredTestPayload>;
discoverTests(uri: Uri): Promise<void>;
discoverTests(
uri: Uri,
executionFactory?: IPythonExecutionFactory,
token?: CancellationToken,
interpreter?: PythonEnvironment,
): Promise<DiscoveredTestPayload>;
): Promise<void>;
}

// interface for execution/runner adapter
export interface ITestExecutionAdapter {
// ** first line old method signature, second line new method signature
runTests(uri: Uri, testIds: string[], profileKind?: boolean | TestRunProfileKind): Promise<ExecutionTestPayload>;
runTests(uri: Uri, testIds: string[], profileKind?: boolean | TestRunProfileKind): Promise<void>;
runTests(
uri: Uri,
testIds: string[],
Expand All @@ -177,7 +177,7 @@ export interface ITestExecutionAdapter {
executionFactory?: IPythonExecutionFactory,
debugLauncher?: ITestDebugLauncher,
interpreter?: PythonEnvironment,
): Promise<ExecutionTestPayload>;
): Promise<void>;
}

// Same types as in python_files/unittestadapter/utils.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
executionFactory?: IPythonExecutionFactory,
token?: CancellationToken,
interpreter?: PythonEnvironment,
): Promise<DiscoveredTestPayload> {
): Promise<void> {
const cSource = new CancellationTokenSource();
const deferredReturn = createDeferred<DiscoveredTestPayload>();
const deferredReturn = createDeferred<void>();

token?.onCancellationRequested(() => {
traceInfo(`Test discovery cancelled.`);
cSource.cancel();
deferredReturn.resolve({ cwd: uri.fsPath, status: 'success' });
deferredReturn.resolve();
});

const name = await startDiscoveryNamedPipe((data: DiscoveredTestPayload) => {
Expand All @@ -61,7 +61,7 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
}, cSource.token);

this.runPytestDiscovery(uri, name, cSource, executionFactory, interpreter, token).then(() => {
deferredReturn.resolve({ cwd: uri.fsPath, status: 'success' });
deferredReturn.resolve();
});

return deferredReturn.promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
executionFactory?: IPythonExecutionFactory,
debugLauncher?: ITestDebugLauncher,
interpreter?: PythonEnvironment,
): Promise<ExecutionTestPayload> {
): Promise<void> {
const deferredTillServerClose: Deferred<void> = utils.createTestingDeferred();

// create callback to handle data received on the named pipe
Expand All @@ -59,12 +59,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
);
runInstance?.token.onCancellationRequested(() => {
traceInfo(`Test run cancelled, resolving 'TillServerClose' deferred for ${uri.fsPath}.`);
const executionPayload: ExecutionTestPayload = {
cwd: uri.fsPath,
status: 'success',
error: '',
};
return executionPayload;
});

try {
Expand All @@ -82,15 +76,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
} finally {
await deferredTillServerClose.promise;
}

// placeholder until after the rewrite is adopted
// TODO: remove after adoption.
const executionPayload: ExecutionTestPayload = {
cwd: uri.fsPath,
status: 'success',
error: '',
};
return executionPayload;
}

private async runTestsNew(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
uri: Uri,
executionFactory?: IPythonExecutionFactory,
token?: CancellationToken,
): Promise<DiscoveredTestPayload> {
): Promise<void> {
const settings = this.configSettings.getSettings(uri);
const { unittestArgs } = settings.testing;
const cwd = settings.testing.cwd && settings.testing.cwd.length > 0 ? settings.testing.cwd : uri.fsPath;

const cSource = new CancellationTokenSource();
const deferredReturn = createDeferred<DiscoveredTestPayload>();
const deferredReturn = createDeferred<void>();

token?.onCancellationRequested(() => {
traceInfo(`Test discovery cancelled.`);
cSource.cancel();
deferredReturn.resolve({ cwd: uri.fsPath, status: 'success' });
deferredReturn.resolve();
});

const name = await startDiscoveryNamedPipe((data: DiscoveredTestPayload) => {
Expand All @@ -83,7 +83,7 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
};

this.runDiscovery(uri, options, name, cwd, cSource, executionFactory).then(() => {
deferredReturn.resolve({ cwd: uri.fsPath, status: 'success' });
deferredReturn.resolve();
});

return deferredReturn.promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
runInstance?: TestRun,
executionFactory?: IPythonExecutionFactory,
debugLauncher?: ITestDebugLauncher,
): Promise<ExecutionTestPayload> {
): Promise<void> {
// deferredTillServerClose awaits named pipe server close
const deferredTillServerClose: Deferred<void> = utils.createTestingDeferred();

Expand Down Expand Up @@ -87,12 +87,6 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
} finally {
await deferredTillServerClose.promise;
}
const executionPayload: ExecutionTestPayload = {
cwd: uri.fsPath,
status: 'success',
error: '',
};
return executionPayload;
}

private async runTestsNew(
Expand Down

0 comments on commit 026d0b4

Please sign in to comment.