Skip to content
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
12 changes: 11 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,24 @@ jobs:
with:
node-version: 20

- name: Setup Pixi
uses: prefix-dev/setup-pixi@273e4808c831936a3ce1a3080c829d9e153143d3
with:
pixi-version: v0.49.0
run-install: false

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Install dependencies
run: npm run ci

- name: Initialize Pixi workspace
working-directory: fixtures/pixi-workspace
run: pixi install --locked

- name: Build extension
run: npm run build

- name: Execute tests
run: xvfb-run -a npm run test
run: xvfb-run -a npm test
25 changes: 16 additions & 9 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
const baseConfig = {
platform: 'desktop',
version: '1.92.2',
files: 'out/**/*.test.js',
// CI environments don't have a monorepo.
workspaceFolder: './',
mocha: {
// Longer timeout because this will download Magic + the SDK.
timeout: 5 * 60 * 1000,
reporter: 'out/test/reporter.js',
},
env: {
// Force magic download.
MOJO_EXTENSION_FORCE_MAGIC: '1',
};

export default defineConfig([
{
...baseConfig,
label: 'default',
workspaceFolder: './',
files: 'out/**/*.test.default.js',
},
{
...baseConfig,
label: 'pixi',
workspaceFolder: 'fixtures/pixi-workspace/',
files: 'out/**/*.test.pixi.js',
},
});
]);
File renamed without changes.
12 changes: 8 additions & 4 deletions extension/lsp/lsp.test.ts → extension/lsp/lsp.test.pixi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ const repoConfig = {
fixtures: path.join(__dirname, '..', '..', 'fixtures'),
};

suite('LSP', () => {
test('LSP should not be loaded on startup', async () => {
suite('LSP', function () {
test('LSP should not be loaded on startup', async function () {
// Restart the extension. Tests run in a shared environment, so if other tests
// have created the LSP, this test will fail otherwise.
await vscode.commands.executeCommand('mojo.extension.restart');

assert.strictEqual(extension.lspManager!.lspClient, undefined);
});

test('LSP should be launched when a Mojo file is opened', async () => {
test('LSP should be launched when a Mojo file is opened', async function () {
// Restart the extension. Tests run in a shared environment, so if other tests
// have created the LSP, this test will fail otherwise.
await vscode.commands.executeCommand('mojo.extension.restart');

const lsp = firstValueFrom(extension.lspManager!.lspClientChanges);

await vscode.workspace.openTextDocument(
vscode.Uri.file(
path.join(repoConfig.fixtures, 'dangling-file', 'dangling_file.mojo'),
path.join(repoConfig.fixtures, 'pixi-workspace', 'main.mojo'),
),
);

Expand Down
20 changes: 20 additions & 0 deletions extension/pyenv.test.pixi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// This file is Modular Inc proprietary.
//
//===----------------------------------------------------------------------===//

import * as assert from 'assert';
import * as vscode from 'vscode';
import { extension } from './extension';
import { SDKKind } from './pyenv';

suite('pyenv', function () {
test('should detect Pixi environments', async function () {
await vscode.commands.executeCommand('mojo.extension.restart');
const sdk = await extension.pyenvManager!.getActiveSDK();
assert.ok(sdk);
assert.strictEqual(sdk.kind, SDKKind.Environment);
assert.strictEqual(sdk.version, '25.5.0.dev2025071605');
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test hardcodes the expected version string. This creates a tight coupling between the test and the fixture configuration, making maintenance difficult when updating versions.

Suggested change
assert.strictEqual(sdk.version, '25.5.0.dev2025071605');
const expectedVersion = await extension.pyenvManager!.getExpectedSDKVersion();
assert.strictEqual(sdk.version, expectedVersion);

Copilot uses AI. Check for mistakes.
});
});
2 changes: 1 addition & 1 deletion extension/test/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VsCodeReporter extends Base {
});

runner.on(EVENT_TEST_PENDING, (test: Test) => {
console.log(indent(`${Base.color('pending', test.title)}`));
console.log(indent(Base.color('pending', `- ${test.title}`)));
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The change adds a hardcoded dash prefix to the test title. Consider using a consistent formatting pattern or making this configurable to maintain consistency with other test output formatting.

Suggested change
console.log(indent(Base.color('pending', `- ${test.title}`)));
console.log(indent(Base.color('pending', formatTestTitle('pending', test.title))));

Copilot uses AI. Check for mistakes.
});

runner.on(EVENT_RUN_END, () => {
Expand Down
2 changes: 2 additions & 0 deletions fixtures/pixi-workspace/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true
2 changes: 2 additions & 0 deletions fixtures/pixi-workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pixi environments
.pixi
2 changes: 2 additions & 0 deletions fixtures/pixi-workspace/main.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fn main():
print("hello world")
3,927 changes: 3,927 additions & 0 deletions fixtures/pixi-workspace/pixi.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions fixtures/pixi-workspace/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[workspace]
authors = ["Lily Brown <lbrown@modular.com>"]
channels = ["https://conda.modular.com/max-nightly", "conda-forge"]
name = "pixi-workspace"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]
modular = "25.5.0.dev2025071605"
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency version is hardcoded to a specific development build. Consider using a more stable version or documenting the reason for this specific dev version to avoid future maintenance issues.

Suggested change
modular = "25.5.0.dev2025071605"
modular = "25.5.0"

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ci": "npm ci && cd ./lsp-proxy && npm ci",
"format": "npx prettier . --write --ignore-path .gitignore",
"publish": "vsce publish",
"test": "rm -r out/ && npm run build && vscode-test"
"test": "vscode-test"
},
"devDependencies": {
"@eslint/js": "^9.30.1",
Expand Down