Skip to content

Commit 3139a6a

Browse files
committed
fix flaky test
1 parent 455a130 commit 3139a6a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/client/terminals/codeExecution/codeExecutionManager.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class CodeExecutionManager implements ICodeExecutionManager {
4545
const newTerminalPerFile = cmd === Commands.Exec_In_Separate_Terminal;
4646

4747
if (useEnvExtension()) {
48+
traceVerbose('Using Environment Extension to execute file in terminal');
4849
try {
4950
await this.executeUsingExtension(file, cmd === Commands.Exec_In_Separate_Terminal);
5051
} catch (ex) {
@@ -124,36 +125,54 @@ export class CodeExecutionManager implements ICodeExecutionManager {
124125
}
125126

126127
private async executeUsingExtension(file: Resource, dedicated: boolean): Promise<void> {
128+
traceVerbose(`executeUsingExtension called with file: ${file?.fsPath}, dedicated: ${dedicated}`);
127129
const codeExecutionHelper = this.serviceContainer.get<ICodeExecutionHelper>(ICodeExecutionHelper);
128130
file = file instanceof Uri ? file : undefined;
129131
let fileToExecute = file ? file : await codeExecutionHelper.getFileToExecute();
130132
if (!fileToExecute) {
133+
traceVerbose('executeUsingExtension: No file to execute, returning early');
131134
return;
132135
}
136+
traceVerbose(`executeUsingExtension: File to execute: ${fileToExecute.fsPath}`);
133137

134138
const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
135139
if (fileAfterSave) {
140+
traceVerbose(`executeUsingExtension: File saved, updated path: ${fileAfterSave.fsPath}`);
136141
fileToExecute = fileAfterSave;
137142
}
138143

139144
// Check on setting terminal.executeInFileDir
140145
const pythonSettings = this.configSettings.getSettings(file);
141146
let cwd = pythonSettings.terminal.executeInFileDir ? path.dirname(fileToExecute.fsPath) : undefined;
147+
traceVerbose(
148+
`executeUsingExtension: CWD: ${cwd}, executeInFileDir: ${pythonSettings.terminal.executeInFileDir}`,
149+
);
142150

143151
// Check on setting terminal.launchArgs
144152
const launchArgs = pythonSettings.terminal.launchArgs;
145153
const totalArgs = [...launchArgs, fileToExecute.fsPath.fileToCommandArgumentForPythonExt()];
154+
traceVerbose(
155+
`executeUsingExtension: Launch args: ${JSON.stringify(launchArgs)}, Total args: ${JSON.stringify(
156+
totalArgs,
157+
)}`,
158+
);
146159

147160
const show = this.shouldTerminalFocusOnStart(fileToExecute);
161+
traceVerbose(`executeUsingExtension: Terminal focus on start: ${show}, Using dedicated terminal: ${dedicated}`);
148162
let terminal: Terminal | undefined;
149163
if (dedicated) {
164+
traceVerbose('executeUsingExtension: Calling runInDedicatedTerminal');
150165
terminal = await runInDedicatedTerminal(fileToExecute, totalArgs, cwd, show);
151166
} else {
167+
traceVerbose('executeUsingExtension: Calling runInTerminal');
152168
terminal = await runInTerminal(fileToExecute, totalArgs, cwd, show);
153169
}
154170

155171
if (terminal) {
172+
traceVerbose(`executeUsingExtension: Terminal created successfully, showing terminal`);
156173
terminal.show();
174+
} else {
175+
traceVerbose('executeUsingExtension: No terminal returned from run function');
157176
}
158177
}
159178

src/testMultiRootWkspc/smokeTests/testExecInTerminal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
# If the output file is given, use that instead.
1212
if len(args) == 2:
13+
print("Using log file from argument:", args[1])
1314
log_file = args[1]
1415

1516
with open(log_file, "a") as f:
17+
print("Writing to log file:", log_file)
1618
f.write(sys.executable)

0 commit comments

Comments
 (0)