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
50 changes: 50 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Tests

on:
push

jobs:
test:
name: Lint, Build & Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint code
run: |
echo "Running ESLint..."
npm run lint

- name: Compile TypeScript
run: |
echo "Compiling TypeScript..."
sh package.sh

- name: Verify compiled output exists
run: |
echo "Checking compiled output..."
if [ ! -f "out/extension.js" ]; then
echo "Error: out/extension.js not found after compilation!"
exit 1
fi
echo "Compiled output verified"

- name: Run tests
run: |
echo "Running test suite..."
xvfb-run -a npm run test
87 changes: 87 additions & 0 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import * as assert from 'assert';
import * as vscode from 'vscode';

suite('Jule Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');

test('Extension should be present', () => {
const ext = vscode.extensions.getExtension('julelang.jule');
assert.ok(ext, 'Extension should be installed');
});

test('Extension should activate', async () => {
const ext = vscode.extensions.getExtension('julelang.jule');
assert.ok(ext, 'Extension should exist');

if (ext && !ext.isActive) {
await ext.activate();
}

assert.ok(ext?.isActive, 'Extension should be activated');
});

test('Jule language should be registered', async () => {
const languages = await vscode.languages.getLanguages();
assert.ok(
languages.includes('jule'),
'Jule language should be registered'
);
});

test('Jule Module language should be registered', async () => {
const languages = await vscode.languages.getLanguages();
assert.ok(
languages.includes('julemod'),
'Jule Module language should be registered'
);
});

test('jule.version command should be registered', async () => {
const commands = await vscode.commands.getCommands();
assert.ok(
commands.includes('jule.version'),
'jule.version command should be registered'
);
});

test('.jule files should use jule language', async () => {
const languages = await vscode.languages.getLanguages();
assert.ok(
languages.includes('jule'),
'jule language should be available for .jule files'
);
});

test('Jule syntax highlighting should be configured', async () => {
const ext = vscode.extensions.getExtension('julelang.jule');
const grammars = ext?.packageJSON.contributes?.grammars;

assert.ok(grammars, 'Grammars should be defined');
assert.ok(
grammars.some((g: any) => g.language === 'jule'),
'Jule grammar should be defined'
);
});

test('Module syntax highlighting should be configured', async () => {
const ext = vscode.extensions.getExtension('julelang.jule');
const grammars = ext?.packageJSON.contributes?.grammars;

assert.ok(grammars, 'Grammars should be defined');
assert.ok(
grammars.some((g: any) => g.language === 'julemod'),
'Module grammar should be defined'
);
});

test('Snippets should be available', async () => {
const ext = vscode.extensions.getExtension('julelang.jule');
const snippets = ext?.packageJSON.contributes?.snippets;

assert.ok(snippets, 'Snippets should be defined');
assert.ok(
snippets.some((s: any) => s.language === 'jule'),
'Jule snippets should be defined'
);
});
});
26 changes: 26 additions & 0 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as path from 'path';
import { runTests } from '@vscode/test-electron';

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './extension.test');

// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ['--disable-extensions'],
});
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
Loading