Skip to content

Commit

Permalink
Avoid querying the Python extension for the interpreter (#528)
Browse files Browse the repository at this point in the history
## Summary

Fix the CI failure on `main`. I think the tests are currently
unpredictable in the sense that the tests could begin _before_ the
server starts which then creates the failure. The main reason I believe
this is happening is because the extension uses a PubSub mechanism here:


https://github.com/astral-sh/ruff-vscode/blob/80d1b13a80ac99afb96a34ae6358d893158a65b8/src/common/python.ts#L250-L259

This change is so that it never hits this by always testing with the
bundled executable and always using the native server.

## Test Plan

I don't really have a good way to test this until it's being triggered
multiple times which will verify the consistency now.
  • Loading branch information
dhruvmanila authored Jul 15, 2024
1 parent efb15e5 commit e3bcd44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>

restartInProgress = true;

if (!vscode.workspace.isTrusted) {
if (!vscode.workspace.isTrusted || process.env.CI == "true") {
lsClient = await restartServer(serverId, serverName, outputChannel, lsClient);

restartInProgress = false;
Expand Down Expand Up @@ -257,7 +257,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
);

setImmediate(async () => {
if (vscode.workspace.isTrusted) {
if (vscode.workspace.isTrusted && process.env.CI == undefined) {
const interpreter = getInterpreterFromSetting(serverId);
if (interpreter === undefined || interpreter.length === 0) {
traceLog(`Python extension loading`);
Expand Down
3 changes: 2 additions & 1 deletion src/testFixture/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
// Always use the bundled Ruff binary for the tests.
// Always use the native server and bundled Ruff binary for the tests.
"ruff.nativeServer": "on",
"ruff.importStrategy": "useBundled",

// Ruff's extension depends on the Python extension which also provides a language server,
Expand Down

0 comments on commit e3bcd44

Please sign in to comment.