Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Jul 19, 2023
1 parent 6d32bf7 commit c6dc362
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/client/testing/testController/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ export class PythonTestServer implements ITestServer, Disposable {
} else {
if (isRun) {
// This means it is running the test
traceInfo(`EJFB Running unittests with arguments: ${args}\r\n`);
traceInfo(`Running unittests with arguments: ${args}\r\n`);
} else {
// This means it is running discovery
traceLog(`EJFB Discovering unittest tests with arguments: ${args}\r\n`);
traceLog(`Discovering unittest tests with arguments: ${args}\r\n`);
}
const deferred = createDeferred<ExecutionResult<string>>();

Expand Down
17 changes: 3 additions & 14 deletions src/client/testing/testController/pytest/pytestDiscoveryAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,15 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
};
const execService = await executionFactory?.createActivatedEnvironment(creationOptions);
// delete UUID following entire discovery finishing.
const deferred2 = createDeferred<ExecutionResult<string>>();
const deferredExec = createDeferred<ExecutionResult<string>>();
const execArgs = ['-m', 'pytest', '-p', 'vscode_pytest', '--collect-only'].concat(pytestArgs);
const result = execService?.execObservable(execArgs, spawnOptions);

result?.proc?.on('close', () => {
deferred2.resolve({ stdout: '', stderr: '' });
deferredExec.resolve({ stdout: '', stderr: '' });
this.testServer.deleteUUID(uuid);
deferred.resolve();
});
await deferred2.promise;

// .then(() => {
// this.testServer.deleteUUID(uuid);
// return deferred.resolve();
// })
// .catch((err) => {
// traceError(`Error while trying to run pytest discovery, \n${err}\r\n\r\n`);
// this.testServer.deleteUUID(uuid);
// return deferred.reject(err);
// });
// return deferred.promise;
await deferredExec.promise;
}
}
19 changes: 5 additions & 14 deletions src/client/testing/testController/pytest/pytestExecutionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ import { PYTEST_PROVIDER } from '../../common/constants';
import { EXTENSION_ROOT_DIR } from '../../../common/constants';
import { startTestIdServer } from '../common/utils';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// (global as any).EXTENSION_ROOT_DIR = EXTENSION_ROOT_DIR;
/**
* Wrapper Class for pytest test execution..
*/

export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
constructor(
public testServer: ITestServer,
Expand Down Expand Up @@ -61,11 +55,8 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
runInstance?.token.onCancellationRequested(() => {
dispose(this.testServer);
});
try {
await this.runTestsNew(uri, testIds, uuid, runInstance, debugBool, executionFactory, debugLauncher);
} finally {
// dispose(this.testServer);
}
await this.runTestsNew(uri, testIds, uuid, runInstance, debugBool, executionFactory, debugLauncher);

// placeholder until after the rewrite is adopted
// TODO: remove after adoption.
const executionPayload: ExecutionTestPayload = {
Expand Down Expand Up @@ -158,19 +149,19 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
const runArgs = [scriptPath, ...testArgs];
traceInfo(`Running pytests with arguments: ${runArgs.join(' ')}\r\n`);

const deferred2 = createDeferred<ExecutionResult<string>>();
const deferredExec = createDeferred<ExecutionResult<string>>();
const result = execService?.execObservable(runArgs, spawnOptions);

runInstance?.token.onCancellationRequested(() => {
result?.proc?.kill();
});

result?.proc?.on('close', () => {
deferred2.resolve({ stdout: '', stderr: '' });
deferredExec.resolve({ stdout: '', stderr: '' });
this.testServer.deleteUUID(uuid);
deferred.resolve();
});
await deferred2.promise;
await deferredExec.promise;
}
} catch (ex) {
traceError(`Error while running tests: ${testIds}\r\n${ex}\r\n\r\n`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
this.testServer.deleteUUID(uuid);
disposable.dispose();
});

// finally {
// this.testServer.deleteUUID(uuid);
// disposable.dispose();
// }
// placeholder until after the rewrite is adopted
// TODO: remove after adoption.
const discoveryPayload: DiscoveredTestPayload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
this.testServer.deleteUUID(uuid);
dispose();
});
try {
await this.runTestsNew(uri, testIds, uuid, runInstance, debugBool, dispose);
} finally {
// dispose(this.testServer);
}
await this.runTestsNew(uri, testIds, uuid, runInstance, debugBool, dispose);
const executionPayload: ExecutionTestPayload = { cwd: uri.fsPath, status: 'success', error: '' };
return executionPayload;
}
Expand Down

0 comments on commit c6dc362

Please sign in to comment.