Skip to content

Commit df97c19

Browse files
committed
wasm append output
1 parent dc34c3c commit df97c19

File tree

7 files changed

+42
-26
lines changed

7 files changed

+42
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,25 @@ jobs:
1616
- name: Setup Node
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 18.x
19+
node-version: 22.x
20+
- name: Cache Cargo
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.cargo/registry/index/
25+
~/.cargo/registry/cache/
26+
~/.cargo/git/db/
27+
target/
28+
!./target/*/*/*.zip
29+
!./target/*/*/*.tar.gz
30+
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }}
31+
- name: Update Rust Toolchain
32+
run: |
33+
rustup update stable
34+
rustup component add rustfmt rust-src clippy
35+
rustup target add aarch64-apple-darwin
36+
rustup target add wasm32-unknown-unknown
37+
cargo install wasm-pack --force
2038
- name: Install Dependencies
2139
run: npm install
2240
- name: Package Extension

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ edition = "2021"
1111
[lib]
1212
crate-type = ["cdylib"]
1313

14-
[build]
15-
target = "wasm32-unknown-unknown"
16-
1714
[dependencies]
18-
lib = { path = "../core/lib", features = ["wasm"] }
15+
lib = { git = "https://github.com/basjoofan/core", tag = "v0.1.0", features = ["wasm"] }
1916
wasm-bindgen = "0.2.104"
2017
wasm-bindgen-futures = "0.4.54"
2118

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Basjoofan",
2+
"name": "basjoofan",
33
"scopeName": "source",
44
"patterns": [
55
{
@@ -23,7 +23,7 @@
2323
"patterns": [
2424
{
2525
"name": "keyword.control",
26-
"match": "\\b(fn|rq|let|if|else|return|while|for)\\b"
26+
"match": "\\b(test|fn|rq|let|if|else|return|while|for)\\b"
2727
}
2828
]
2929
},

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"compile": "tsc -p ./",
3030
"lint": "eslint \"src/**/*.ts\"",
3131
"watch": "tsc -watch -p ./",
32-
"wasm:pack": "wasm-pack build --target nodejs --out-dir ./node_modules/lib",
32+
"wasm:pack": "wasm-pack build --target nodejs --out-dir ./node_modules/lib --release",
3333
"package": "vsce package"
3434
},
3535
"devDependencies": {
@@ -52,7 +52,7 @@
5252
"extensions": [
5353
".fan"
5454
],
55-
"configuration": "language-configuration.json",
55+
"configuration": "language/configuration.json",
5656
"icon": {
5757
"light": "icons/file.png",
5858
"dark": "icons/file.png"
@@ -63,7 +63,7 @@
6363
{
6464
"language": "basjoofan",
6565
"scopeName": "source",
66-
"path": "syntaxes/language.json"
66+
"path": "language/syntaxes.json"
6767
}
6868
]
6969
}

sample/test/test.fan

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ test post {
4747

4848
test postForm {
4949
let response = postForm->;
50-
response.status
50+
let status = response.status
51+
println("status: {status}")
5152
}
5253

5354
test postMultipart {
5455
let response = postMultipart->;
55-
response
56+
let body = response.body
57+
println("body: {body}")
5658
}

src/extension.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import * as vscode from 'vscode';
22
import { run_test } from 'lib';
33

44
export async function activate(context: vscode.ExtensionContext) {
5-
Object.assign(globalThis, {
5+
Object.assign(global, {
66
readFileContent: async function (filePath: string): Promise<Uint8Array> {
7-
const content = await vscode.workspace.fs.readFile(vscode.Uri.file(filePath));
8-
return content;
7+
return await vscode.workspace.fs.readFile(vscode.Uri.file(filePath));
98
}
109
});
1110
const ctrl = vscode.tests.createTestController('BasjoofanTestController', 'Basjoofan');
@@ -65,19 +64,9 @@ export async function activate(context: vscode.ExtensionContext) {
6564
}
6665
};
6766

68-
const appendOutput = (chunk: string) => {
69-
for (; ;) {
70-
const index = chunk.indexOf('\n');
71-
if (index === -1) break;
72-
const line = chunk.substring(0, index);
73-
chunk = chunk.substring(index + 1);
74-
run.appendOutput(`${line}\r\n`);
75-
}
76-
};
77-
7867
const runTestQueue = async () => {
7968
for (const test of queue) {
80-
run.appendOutput(`Running ${test.uri} ${test.label}\r\n`);
69+
run.appendOutput(`Running ${test.uri} ${test.label}\r\n`, undefined, test);
8170
if (run.token.isCancellationRequested) {
8271
run.skipped(test);
8372
} else {
@@ -91,6 +80,16 @@ export async function activate(context: vscode.ExtensionContext) {
9180
text += await vscode.workspace.openTextDocument(file).then(doc => doc.getText());
9281
}
9382
}
83+
const appendOutput = (chunk: string): void => {
84+
for (; ;) {
85+
const index = chunk.indexOf('\n');
86+
if (index === -1) break;
87+
const line = chunk.substring(0, index);
88+
chunk = chunk.substring(index + 1);
89+
run.appendOutput(`${line}\r\n`, undefined, test);
90+
}
91+
};
92+
Object.assign(global, { appendOutput: appendOutput });
9493
const flag = await new Promise<boolean>(resolve => {
9594
run_test(text, test.label, workspace!.uri.fsPath).then(result => {
9695
appendOutput(result);

0 commit comments

Comments
 (0)