Skip to content

Commit dd035b4

Browse files
committed
Merge branch 'codex/issue-132-passing-min-vscode' into codex/phase-4-test-base
2 parents e8f73cf + 496262e commit dd035b4

6 files changed

Lines changed: 56 additions & 27 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ jobs:
7676
grep -Fx 'extension/media/webview.js' /tmp/liquid-java-vsix-files.txt
7777
7878
integration:
79-
name: VS Code integration
80-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
79+
name: VS Code integration (${{ matrix.version }})
8180
runs-on: ubuntu-latest
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
version: ${{ (github.event_name == 'pull_request' || github.ref == 'refs/heads/main') && fromJSON('["stable", "minimum"]') || fromJSON('["stable"]') }}
8285

8386
defaults:
8487
run:
@@ -108,15 +111,16 @@ jobs:
108111
- name: Build server
109112
run: npm run build:server
110113

111-
- name: Run VS Code stable smoke test
114+
- name: Run VS Code fixture tests
112115
env:
113116
JAVA_HOME: ${{ steps.java.outputs.path }}
117+
VSCODE_TEST_VERSION: ${{ matrix.version }}
114118
run: xvfb-run -a npm test
115119

116120
- name: Upload VS Code logs
117121
if: failure()
118122
uses: actions/upload-artifact@v4
119123
with:
120-
name: vscode-logs
124+
name: vscode-logs-${{ matrix.version }}
121125
path: client/.vscode-test/user-data/logs
122126
if-no-files-found: ignore

‎client/.vscode-test.mjs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import { readFileSync } from 'node:fs';
12
import { defineConfig } from '@vscode/test-cli';
3+
import { minVersion } from 'semver';
24

3-
export default defineConfig({
4-
files: 'out/test/**/*.test.js',
5-
version: 'stable',
6-
workspaceFolder: 'test-fixtures/failing',
5+
const { engines } = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
6+
const version = process.env.VSCODE_TEST_VERSION === 'minimum'
7+
? minVersion(engines.vscode).version
8+
: 'stable';
9+
10+
export default defineConfig(['failing', 'passing'].map(fixture => ({
11+
label: fixture,
12+
files: fixture === 'failing' ? 'out/test/**/*.test.js' : 'out/test/smoke.test.js',
13+
version,
14+
workspaceFolder: `test-fixtures/${fixture}`,
715
extensionDevelopmentPath: '.',
816
launchArgs: ['--disable-extensions', '--disable-workspace-trust'],
917
mocha: { ui: 'tdd', timeout: 120_000 },
10-
});
18+
})));

‎client/package-lock.json‎

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎client/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@
170170
"@eslint/js": "^9.39.0",
171171
"@types/mocha": "^10.0.10",
172172
"@types/node": "^24.7.2",
173-
"@types/vscode": "^1.82.0",
173+
"@types/vscode": "~1.82.0",
174174
"@vscode/test-cli": "^0.0.15",
175175
"@vscode/test-electron": "^3.1.0",
176176
"@vscode/vsce": "^3.0.0",
177177
"eslint": "^9.39.0",
178178
"jsonc-parser": "^0.4.2",
179179
"minimist": "^1.2.7",
180+
"semver": "^7.7.4",
180181
"ts-loader": "^9.5.4",
181182
"typescript": "~5.3.0",
182183
"typescript-eslint": "^8.0.0",

‎client/src/test/smoke.test.ts‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { LJDiagnostic } from '../types/diagnostics';
55
import type { LiquidJavaTestApi } from '../types/test-api';
66

77
suite('Bundled LiquidJava extension', () => {
8-
test('activates, becomes ready, and verifies the failing fixture', async () => {
8+
test('activates, becomes ready, and verifies its isolated fixture', async () => {
99
const installed = vscode.extensions.getExtension<LiquidJavaTestApi>('AlcidesFonseca.liquid-java');
1010
assert.ok(installed, 'LiquidJava must be loaded in the Extension Host');
1111
assert.equal(installed.packageJSON.main, './dist/extension.js');
@@ -16,12 +16,16 @@ suite('Bundled LiquidJava extension', () => {
1616
assert.notEqual(api.getState().status, 'stopped');
1717

1818
const workspace = vscode.workspace.workspaceFolders?.[0];
19-
assert.ok(workspace, 'the failing fixture must have its own workspace');
20-
const uri = vscode.Uri.joinPath(workspace.uri, 'src/main/java/FailingRefinement.java');
19+
assert.ok(workspace, 'the fixture must have its own workspace');
20+
const passing = path.basename(workspace.uri.fsPath) === 'passing';
21+
const file = passing ? 'PassingRefinement.java' : 'FailingRefinement.java';
22+
const uri = vscode.Uri.joinPath(workspace.uri, `src/main/java/${file}`);
2123
const subscriptions: vscode.Disposable[] = [];
2224
const nextFixtureDiagnostics = () => new Promise<LJDiagnostic[]>((resolve) => {
2325
const subscription = api.onDiagnostics((diagnostics) => {
24-
if (diagnostics.some(d => d.type === 'refinement-error' && path.resolve(d.file) === uri.fsPath)) {
26+
const matches = passing ? diagnostics.length === 0
27+
: diagnostics.some(d => d.type === 'refinement-error' && vscode.Uri.file(path.resolve(d.file)).fsPath === uri.fsPath);
28+
if (matches) {
2529
subscription.dispose();
2630
resolve(diagnostics);
2731
}
@@ -38,12 +42,17 @@ suite('Bundled LiquidJava extension', () => {
3842
const manualDiagnostics = nextFixtureDiagnostics();
3943
await vscode.commands.executeCommand('liquidjava.verify');
4044
const diagnostics = await manualDiagnostics;
41-
const error = diagnostics.find(d => d.type === 'refinement-error' && path.resolve(d.file) === uri.fsPath);
42-
assert.ok(error);
43-
assert.equal(error.category, 'error');
44-
assert.equal(error.title, 'Refinement Error');
45-
assert.ok(error.position, 'the diagnostic must identify the invalid assignment');
46-
assert.equal(api.getState().status, 'failed');
45+
if (passing) {
46+
assert.deepEqual(diagnostics, [], 'correct code must emit an explicit empty result');
47+
assert.equal(api.getState().status, 'passed');
48+
} else {
49+
const error = diagnostics.find(d => d.type === 'refinement-error' && vscode.Uri.file(path.resolve(d.file)).fsPath === uri.fsPath);
50+
assert.ok(error);
51+
assert.equal(error.category, 'error');
52+
assert.equal(error.title, 'Refinement Error');
53+
assert.ok(error.position, 'the diagnostic must identify the invalid assignment');
54+
assert.equal(api.getState().status, 'failed');
55+
}
4756
assert.deepEqual(api.getState().diagnostics, diagnostics);
4857
} finally {
4958
subscriptions.forEach(subscription => subscription.dispose());
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import liquidjava.specification.Refinement;
2+
3+
public class PassingRefinement {
4+
@Refinement("_ > 0")
5+
int positive = 1;
6+
}

0 commit comments

Comments
 (0)