Skip to content

Commit 7763016

Browse files
committed
add logging + move service container
1 parent 36cac6f commit 7763016

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/client/testing/testController/pytest/pytestExecutionAdapter.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
108108
const settings = this.configSettings.getSettings(uri);
109109
const { pytestArgs } = settings.testing;
110110
const cwd = settings.testing.cwd && settings.testing.cwd.length > 0 ? settings.testing.cwd : uri.fsPath;
111+
console.log('EJFB, runTestNew');
111112
// get and edit env vars
112113
const mutableEnv = {
113114
...(await this.envVarsService?.getEnvironmentVariables(uri)),
114115
};
116+
console.log('EJFB after mutableEnv');
115117
// get python path from mutable env, it contains process.env as well
116118
const pythonPathParts: string[] = mutableEnv.PYTHONPATH?.split(path.delimiter) ?? [];
117119
const pythonPathCommand = [fullPluginPath, ...pythonPathParts].join(path.delimiter);
@@ -121,15 +123,17 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
121123
mutableEnv.COVERAGE_ENABLED = 'True';
122124
}
123125
const debugBool = profileKind && profileKind === TestRunProfileKind.Debug;
124-
126+
console.log('EJFB after debug Bool');
125127
// Create the Python environment in which to execute the command.
126128
const creationOptions: ExecutionFactoryCreateWithEnvironmentOptions = {
127129
allowEnvironmentFetchExceptions: false,
128130
resource: uri,
129131
interpreter,
130132
};
131133
// need to check what will happen in the exec service is NOT defined and is null
134+
console.log('EJFB, before exec service');
132135
const execService = await executionFactory?.createActivatedEnvironment(creationOptions);
136+
console.log('EJFB, after exec service');
133137
try {
134138
// Remove positional test folders and files, we will add as needed per node
135139
let testArgs = removePositionalFoldersAndFiles(pytestArgs);
@@ -157,7 +161,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
157161
env: mutableEnv,
158162
token: runInstance?.token,
159163
};
160-
164+
console.log('EJFB, before debug check');
161165
if (debugBool) {
162166
const launchOptions: LaunchOptions = {
163167
cwd,
@@ -181,6 +185,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
181185

182186
let resultProc: ChildProcess | undefined;
183187

188+
console.log('EJFB, before run instance creation');
184189
runInstance?.token.onCancellationRequested(() => {
185190
traceInfo(`Test run cancelled, killing pytest subprocess for workspace ${uri.fsPath}`);
186191
// if the resultProc exists just call kill on it which will handle resolving the ExecClose deferred, otherwise resolve the deferred here.
@@ -192,7 +197,9 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
192197
}
193198
});
194199

200+
console.log('EJFB, before exec observable');
195201
const result = execService?.execObservable(runArgs, spawnOptions);
202+
console.log('EJFB, after exec observable');
196203
resultProc = result?.proc;
197204

198205
// Take all output from the subprocess and add it to the test output channel. This will be the pytest output.
@@ -219,6 +226,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
219226

220227
result?.proc?.on('close', (code, signal) => {
221228
traceVerbose('Test run finished, subprocess closed.');
229+
console.log('EJFB, process closed');
222230
// if the child has testIds then this is a run request
223231
// if the child process exited with a non-zero exit code, then we need to send the error payload.
224232
if (code !== 0 && testIds) {
@@ -239,6 +247,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
239247
deferredTillExecClose.resolve();
240248
serverCancel.cancel();
241249
});
250+
console.log('EJFB, await deferredTillExecClose');
242251
await deferredTillExecClose.promise;
243252
}
244253
} catch (ex) {
@@ -251,6 +260,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
251260
status: 'success',
252261
error: '',
253262
};
263+
console.log('EJFB, returning execution payload');
254264
return executionPayload;
255265
}
256266
}

src/test/testing/common/testingAdapter.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ suite('End to End Tests: test adapters', () => {
8484
// create symlink for specific symlink test
8585
const target = rootPathSmallWorkspace;
8686
const dest = rootPathDiscoverySymlink;
87+
serviceContainer = (await initialize()).serviceContainer;
8788
try {
8889
fs.symlink(target, dest, 'dir', (err) => {
8990
if (err) {
@@ -105,7 +106,6 @@ suite('End to End Tests: test adapters', () => {
105106
});
106107

107108
setup(async () => {
108-
serviceContainer = (await initialize()).serviceContainer;
109109
getPixiStub = sinon.stub(pixi, 'getPixi');
110110
getPixiStub.resolves(undefined);
111111

@@ -1143,7 +1143,6 @@ suite('End to End Tests: test adapters', () => {
11431143
let callCount = 0;
11441144
let failureOccurred = false;
11451145
let failureMsg = '';
1146-
console.log('EFB: beginning function');
11471146
resultResolver._resolveExecution = async (data, _token?) => {
11481147
// do the following asserts for each time resolveExecution is called, should be called once per test.
11491148
console.log(`pytest execution adapter seg fault error handling \n ${JSON.stringify(data)}`);

0 commit comments

Comments
 (0)