Skip to content
Open
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
22 changes: 19 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: E2E and Unit tests
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -25,7 +25,6 @@ jobs:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- name: Fetch Sources
uses: actions/checkout@v4
Expand All @@ -44,11 +43,20 @@ jobs:
node-version: 22.x
cache: "yarn"

- name: Setup EMSDK
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.54
actions-cache-folder: "emsdk-cache"

- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: false
run: yarn install --immutable

- name: Build WASM
run: yarn grammar:wasm

- name: Build Extension
run: yarn build

Expand All @@ -62,3 +70,11 @@ jobs:
- name: Run e2e tests
if: matrix.os != 'ubuntu-latest'
run: yarn run test:e2e

- name: Upload Language Server Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: language-server-logs-${{ matrix.os }}
path: dist/ton-language-server.log
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"lint": "eslint --cache .",
"fmt": "prettier --write -l --cache .",
"fmt:check": "prettier --check --cache .",
"grammar:wasm": "yarn grammar:tolk:wasm && yarn grammar:fift:wasm && yarn grammar:tlb:wasm",
"grammar:wasm": "yarn grammar:tolk:wasm && yarn grammar:func:wasm && yarn grammar:fift:wasm && yarn grammar:tlb:wasm",
"grammar:tolk:wasm": "cd server/src/languages/tolk/tree-sitter-tolk && tree-sitter generate && tree-sitter build --wasm",
"grammar:func:wasm": "cd server/src/languages/func/tree-sitter-func && tree-sitter generate && tree-sitter build --wasm",
"grammar:fift:wasm": "cd server/src/languages/fift/tree-sitter-fift && tree-sitter generate && tree-sitter build --wasm",
Expand Down
9 changes: 9 additions & 0 deletions server/src/e2e/runTolkTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 TON Studio
import * as path from "node:path"
import {runTests} from "@vscode/test-electron"
import {mkdirSync} from "node:fs"

// eslint-disable-next-line functional/type-declaration-immutability
interface TestRunOptions {
Expand Down Expand Up @@ -112,6 +113,14 @@ async function main(): Promise<void> {
const extensionTestsPath = path.resolve(__dirname, "./out/tolk/index.js")
const testWorkspace = path.resolve(__dirname, "../../../test-workspace")

mkdirSync(testWorkspace, {recursive: true})

if (options.verbose) {
console.log(" extensionDevelopmentPath:", extensionDevelopmentPath)
console.log(" extensionTestsPath:", extensionTestsPath)
console.log(" testWorkspace:", testWorkspace)
}

await runTests({
extensionDevelopmentPath,
extensionTestsPath,
Expand Down
1 change: 1 addition & 0 deletions server/src/e2e/tolk/documentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ suite("Documentation Test Suite", () => {
.trim()
.replace(this.workingDir(), "<working-dir>")
.replace(workingDir, "<working-dir>")
.replace(/\\/g, "/")

const expected = testCase.expected
.split("\n")
Expand Down
6 changes: 4 additions & 2 deletions server/src/e2e/tolk/multifile-resolving.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ suite("Multi file Resolve Test Suite", () => {
if (target instanceof vscode.Location) {
return `${this.formatLocation(pos)} -> ${this.formatLocation(
target.range.start,
)} (${path.relative(this.testDir, target.uri.fsPath)}) resolved`
)} (${normalizePath(path.relative(this.testDir, target.uri.fsPath))}) resolved`
}

return `${this.formatLocation(pos)} -> ${this.formatLocation(
target.targetRange.start,
)} (${path.relative(this.testDir, target.targetUri.fsPath)}) resolved`
)} (${normalizePath(path.relative(this.testDir, target.targetUri.fsPath))}) resolved`
})
.join("\n")
}
Expand Down Expand Up @@ -109,3 +109,5 @@ suite("Multi file Resolve Test Suite", () => {

testSuite.runTestsFromDirectory("multifile-resolving")
})

const normalizePath = (path: string): string => path.replace(/\\/g, "/")
95 changes: 0 additions & 95 deletions server/src/e2e/tolk/testcases/completion-select/snippets.test
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,6 @@ fun foo() {
var name<caret>: int = value;
}

========================================================================
If snippet
========================================================================
fun foo() {
if<caret>
}
------------------------------------------------------------------------
fun foo() {
if (condition<caret>) {

}
}

========================================================================
If-else snippet
========================================================================
fun foo() {
ife<caret>
}
------------------------------------------------------------------------
fun foo() {
if (condition<caret>) {

} else {

}
}

========================================================================
Do while snippet
========================================================================
fun foo() {
while<caret>
}
------------------------------------------------------------------------
fun foo() {
do {

} while (condition<caret>);
}

========================================================================
Repeat snippet
========================================================================
fun foo() {
repeat<caret>
}
------------------------------------------------------------------------
fun foo() {
repeat(count<caret>) {

}
}

========================================================================
Try snippet
========================================================================
Expand All @@ -108,44 +54,3 @@ fun foo() {
<caret>
}
}

========================================================================
Try catch snippet
========================================================================
fun foo() {
tryc<caret>
}
------------------------------------------------------------------------
fun foo() {
try {
<caret>
} catch (e) {

}
}

========================================================================
Match snippet
========================================================================
fun foo() {
match<caret>
}
------------------------------------------------------------------------
fun foo() {
match (condition<caret>) {

}
}

========================================================================
Match snippet as an expression
========================================================================
fun foo() {
val a = match<caret>
}
------------------------------------------------------------------------
fun foo() {
val a = match (condition<caret>) {

}
}
11 changes: 0 additions & 11 deletions server/src/e2e/tolk/testcases/documentation/auto-return-type.test
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,3 @@ fun int.<caret>foo(self) {}
```tolk
fun int.foo(self): void
```

========================================================================
Instance method with auto return type documentation: return self
========================================================================
fun int.<caret>foo(self) {
return self
}
------------------------------------------------------------------------
```tolk
fun int.foo(self): int
```
2 changes: 1 addition & 1 deletion server/src/e2e/tolk/testcases/documentation/imports.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Import path from stdlib documentation
import "<caret>@stdlib/common"
------------------------------------------------------------------------
```tolk
import "<working-dir>/tolk-stdlib/common.tolk"
import "../server/src/e2e/tolk/tolk-stdlib/common.tolk"
```

========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SnakeString = slice
fun SnakeString.unpackFromSlice(mutate s: slice) {}
fun SnakeString.packToBuilder(self, mutate b: builder) {}
------------------------------------------------------------------------
3 0:5 to 0:16 Type alias 'SnakeString' is never used (tolk)
no issues

========================================================================
Unused top level declarations
Expand Down
2 changes: 1 addition & 1 deletion server/src/e2e/tolk/testcases/types2/assign-smartcast.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Smart cast on assignment, union type value
========================================================================
fun main() {
val value: int | bool | null = 10 as int | bool;
//! ^ int | bool
//! ^ int | bool | null
value;
//! ^ int | bool
}
Expand Down
6 changes: 2 additions & 4 deletions server/src/e2e/tolk/testcases/types2/generic-structs.test
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ fun main() {
//! ^ Ok<int>
if (r is Ok) { r; }
//! ^ Ok<int>
if (r is OkAlias<int>) { r; }
//! ^ OkAlias<int>
if (r !is OkAlias<int>) { r; }
//! ^ Err<slice>
if (r !is Ok<int>) { r; }
//! ^ Err<slice>
if (r is Ok<int> && r !is Err<slice> && r is Ok) { r; }
//! ^ Ok<int>
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/e2e/tolk/testcases/types2/match.test
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fun main() {
},
null => {
value;
//! ^ int?
//! ^ null
}
}
}
Expand Down
Binary file not shown.
1 change: 0 additions & 1 deletion server/src/languages/tolk/tree-sitter-tolk/main.tolk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fun t<T>() {}

// fun Container<T>.getItem(self) { return self.item; }
// fun builder.add(mutate self) { }
Expand Down
2 changes: 1 addition & 1 deletion server/src/languages/tolk/types/ty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ export function subtractTypes(left: Ty | null, right: Ty): Ty {
}
} else if (left.contains(right)) {
for (const leftVariant of left.elements) {
if (!leftVariant.baseType().equals(right.baseType())) {
if (!leftVariant.unwrapAlias().equals(right.unwrapAlias())) {
restVariants.push(leftVariant)
}
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ connection.onInitialize(async (initParams: lsp.InitializeParams): Promise<lsp.In

workspaceFolders = initParams.workspaceFolders ?? []
const opts = initParams.initializationOptions as ClientOptions | undefined
console.log("initializationOptions:", opts)

const treeSitterUri = opts?.treeSitterWasmUri ?? `${__dirname}/tree-sitter.wasm`
const tolkLangUri = opts?.tolkLangWasmUri ?? `${__dirname}/tree-sitter-tolk.wasm`
const funcLangUri = opts?.funcLangWasmUri ?? `${__dirname}/tree-sitter-func.wasm`
Expand Down
Loading