Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly build deactivate commands for powershell #22570

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ITerminalManager } from '../../common/application/types';
import { pathExists } from '../../common/platform/fs-paths';
import { _SCRIPTS_DIR } from '../../common/process/internal/scripts/constants';
import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors/baseShellDetector';
import { TerminalShellType } from '../../common/terminal/types';
import { ITerminalHelper, TerminalShellType } from '../../common/terminal/types';
import { Resource } from '../../common/types';
import { waitForCondition } from '../../common/utils/async';
import { cache } from '../../common/utils/decorators';
Expand Down Expand Up @@ -37,6 +37,7 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
constructor(
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(ITerminalHelper) private readonly terminalHelper: ITerminalHelper,
) {}

@cache(-1, true)
Expand All @@ -58,7 +59,11 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
globalInterpreters.length > 0 && globalInterpreters[0] ? globalInterpreters[0].path : 'python';
const checkIfFileHasBeenCreated = () => pathExists(outputFile);
const stopWatch = new StopWatch();
terminal.sendText(`${interpreterPath} "${this.envVarScript}" "${outputFile}"`);
const command = this.terminalHelper.buildCommandForTerminal(shellType, interpreterPath, [
this.envVarScript,
outputFile,
]);
terminal.sendText(command);
await waitForCondition(checkIfFileHasBeenCreated, 30_000, `"${outputFile}" file not created`);
traceVerbose(`Time taken to get env vars using terminal is ${stopWatch.elapsedTime}ms`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ suite('Terminal Environment Variable Collection Service', () => {

test('Also prepend deactivate script location if available', async () => {
reset(terminalDeactivateService);
when(terminalDeactivateService.initializeScriptParams(anything())).thenResolve();
when(terminalDeactivateService.initializeScriptParams(anything())).thenReject(); // Verify we swallow errors from here
when(terminalDeactivateService.getScriptLocation(anything(), anything())).thenResolve('scriptLocation');
const processEnv = { PATH: 'hello/1/2/3' };
reset(environmentActivationService);
Expand Down
Loading