Skip to content

Commit 693e21e

Browse files
committed
ci: add a test task that includes a few basic tests
1 parent d4e719c commit 693e21e

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tests
2+
3+
on:
4+
push
5+
6+
jobs:
7+
test:
8+
name: Lint, Build & Test
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [20.x, 22.x]
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Lint code
29+
run: |
30+
echo "🔍 Running ESLint..."
31+
npm run lint
32+
33+
- name: Compile TypeScript
34+
run: |
35+
echo "📦 Compiling TypeScript..."
36+
sh package.sh
37+
38+
- name: Verify compiled output exists
39+
run: |
40+
echo "✅ Checking compiled output..."
41+
if [ ! -f "out/extension.js" ]; then
42+
echo "❌ Error: out/extension.js not found after compilation!"
43+
exit 1
44+
fi
45+
echo "✅ Compiled output verified"
46+
47+
- name: Run tests
48+
run: |
49+
echo "🧪 Running test suite..."
50+
xvfb-run -a npm run test

src/test/extension.test.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import * as assert from 'assert';
2+
import * as vscode from 'vscode';
3+
4+
suite('Jule Extension Test Suite', () => {
5+
vscode.window.showInformationMessage('Start all tests.');
6+
7+
test('Extension should be present', () => {
8+
const ext = vscode.extensions.getExtension('julelang.jule');
9+
assert.ok(ext, 'Extension should be installed');
10+
});
11+
12+
test('Extension should activate', async () => {
13+
const ext = vscode.extensions.getExtension('julelang.jule');
14+
assert.ok(ext, 'Extension should exist');
15+
16+
if (ext && !ext.isActive) {
17+
await ext.activate();
18+
}
19+
20+
assert.ok(ext?.isActive, 'Extension should be activated');
21+
});
22+
23+
test('Jule language should be registered', async () => {
24+
const languages = await vscode.languages.getLanguages();
25+
assert.ok(
26+
languages.includes('jule'),
27+
'Jule language should be registered'
28+
);
29+
});
30+
31+
test('Jule Module language should be registered', async () => {
32+
const languages = await vscode.languages.getLanguages();
33+
assert.ok(
34+
languages.includes('julemod'),
35+
'Jule Module language should be registered'
36+
);
37+
});
38+
39+
test('jule.version command should be registered', async () => {
40+
const commands = await vscode.commands.getCommands();
41+
assert.ok(
42+
commands.includes('jule.version'),
43+
'jule.version command should be registered'
44+
);
45+
});
46+
47+
test('.jule files should use jule language', async () => {
48+
const languages = await vscode.languages.getLanguages();
49+
assert.ok(
50+
languages.includes('jule'),
51+
'jule language should be available for .jule files'
52+
);
53+
});
54+
55+
test('Jule syntax highlighting should be configured', async () => {
56+
const ext = vscode.extensions.getExtension('julelang.jule');
57+
const grammars = ext?.packageJSON.contributes?.grammars;
58+
59+
assert.ok(grammars, 'Grammars should be defined');
60+
assert.ok(
61+
grammars.some((g: any) => g.language === 'jule'),
62+
'Jule grammar should be defined'
63+
);
64+
});
65+
66+
test('Module syntax highlighting should be configured', async () => {
67+
const ext = vscode.extensions.getExtension('julelang.jule');
68+
const grammars = ext?.packageJSON.contributes?.grammars;
69+
70+
assert.ok(grammars, 'Grammars should be defined');
71+
assert.ok(
72+
grammars.some((g: any) => g.language === 'julemod'),
73+
'Module grammar should be defined'
74+
);
75+
});
76+
77+
test('Snippets should be available', async () => {
78+
const ext = vscode.extensions.getExtension('julelang.jule');
79+
const snippets = ext?.packageJSON.contributes?.snippets;
80+
81+
assert.ok(snippets, 'Snippets should be defined');
82+
assert.ok(
83+
snippets.some((s: any) => s.language === 'jule'),
84+
'Jule snippets should be defined'
85+
);
86+
});
87+
});

src/test/runTest.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as path from 'path';
2+
import { runTests } from '@vscode/test-electron';
3+
4+
async function main() {
5+
try {
6+
// The folder containing the Extension Manifest package.json
7+
// Passed to `--extensionDevelopmentPath`
8+
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
9+
10+
// The path to test runner
11+
// Passed to --extensionTestsPath
12+
const extensionTestsPath = path.resolve(__dirname, './extension.test');
13+
14+
// Download VS Code, unzip it and run the integration test
15+
await runTests({
16+
extensionDevelopmentPath,
17+
extensionTestsPath,
18+
launchArgs: ['--disable-extensions'],
19+
});
20+
} catch (err) {
21+
console.error('Failed to run tests');
22+
process.exit(1);
23+
}
24+
}
25+
26+
main();

0 commit comments

Comments
 (0)