Skip to content

Commit 7869694

Browse files
Refine CI on to enable WERROR and test on emcc
1 parent 5a7adc1 commit 7869694

14 files changed

+1472
-3
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,18 @@ jobs:
7878
run: |
7979
docker run -di --name emscripten -v $(pwd):/src emscripten/emsdk:latest bash
8080
docker exec emscripten emcc -v
81-
docker exec emscripten emcmake cmake .
82-
docker exec emscripten make -j 2 VERBOSE=1
81+
docker exec emscripten emcmake cmake -B emscripten -DWERROR=ON -DBUILD_TESTS=OFF
82+
docker exec emscripten bash -c "cd /src/emscripten && emmake make -j $(nproc)"
83+
84+
- uses: actions/setup-node@v3
85+
with:
86+
node-version: "^18.15.0"
87+
- name: test
88+
run: |
89+
cd ./test/wabt.js
90+
npm ci
91+
npm run test
92+
8393
wasi:
8494
name: wasi
8595
runs-on: ubuntu-latest

src/c-writer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ void CWriter::SerializeFuncType(const FuncType& func_type,
16331633
*next_byte++ = MangleType(func_type.GetResultType(i));
16341634
}
16351635

1636-
assert(next_byte - mangled_signature == len);
1636+
assert(next_byte - mangled_signature == static_cast<ptrdiff_t>(len));
16371637

16381638
// step 4: SHA-256 the whole string
16391639
sha256({mangled_signature, len}, serialized_type);

test/wabtjs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function add(a: v128, b: v128): v128 {
2+
return v128.add<i32>(a, b);
3+
}
70 Bytes
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(module
2+
(type $v128_v128_=>_v128 (func (param v128 v128) (result v128)))
3+
(memory $0 0)
4+
(table $0 1 funcref)
5+
(export "memory" (memory $0))
6+
(export "add" (func $tests/assembly/module-features/add))
7+
(func $tests/assembly/module-features/add (; 0 ;) (param $0 v128) (param $1 v128) (result v128)
8+
local.get $0
9+
local.get $1
10+
i32x4.add
11+
)
12+
)

test/wabtjs/assembly/module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function add(a: i32, b: i32): i32 {
2+
return a + b;
3+
}

test/wabtjs/assembly/module.wasm

69 Bytes
Binary file not shown.

test/wabtjs/assembly/module.wat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(module
2+
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
3+
(memory $0 0)
4+
(table $0 1 funcref)
5+
(export "memory" (memory $0))
6+
(export "add" (func $tests/assembly/module/add))
7+
(func $tests/assembly/module/add (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
8+
local.get $0
9+
local.get $1
10+
i32.add
11+
)
12+
)

test/wabtjs/assembly/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../../node_modules/assemblyscript/std/assembly.json",
3+
"include": [
4+
"./**/*.ts"
5+
]
6+
}

test/wabtjs/index.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
"use strict"
2+
var fs = require("fs");
3+
var test = require("tape");
4+
5+
// This test case exists to catch the most obvious issues before pushing the binary back to GitHub.
6+
// It's not intended to be a full test suite, but feel free to extend it / send a PR if necessary!
7+
8+
require("../../emscripten/libwabt")().then(wabt => {
9+
10+
var mod;
11+
test("loading a binary module", function (test) {
12+
var buffer = new Uint8Array(
13+
fs.readFileSync(__dirname + "/assembly/module.wasm")
14+
);
15+
test.doesNotThrow(function () {
16+
mod = wabt.readWasm(buffer, { readDebugNames: true });
17+
});
18+
test.ok(mod && typeof mod.toBinary === "function", "should return a module");
19+
test.end();
20+
});
21+
22+
test("loading a binary module (with features)", function (test) {
23+
var buffer = new Uint8Array(
24+
fs.readFileSync(__dirname + "/assembly/module-features.wasm")
25+
);
26+
test.doesNotThrow(function () {
27+
mod = wabt.readWasm(buffer, {
28+
readDebugNames: true,
29+
});
30+
});
31+
test.ok(mod && typeof mod.toBinary === "function", "should return a module");
32+
test.end();
33+
});
34+
35+
test("modifying a module", function (test) {
36+
test.doesNotThrow(function () {
37+
mod.generateNames();
38+
mod.applyNames();
39+
});
40+
test.end();
41+
});
42+
43+
test("emitting a module", function (test) {
44+
var text, binaryRes;
45+
test.doesNotThrow(function () {
46+
text = mod.toText({ foldExprs: true, inlineExport: false });
47+
binaryRes = mod.toBinary({ write_debug_names: true });
48+
});
49+
test.ok(
50+
typeof text === "string" && text.length,
51+
"should return a string from calling Module#toText"
52+
);
53+
test.ok(
54+
binaryRes &&
55+
binaryRes.buffer &&
56+
binaryRes.buffer.length &&
57+
typeof binaryRes.log === "string",
58+
"should return a binary result from calling Module#toBinary"
59+
);
60+
test.end();
61+
});
62+
63+
test("destroying a module", function (test) {
64+
test.doesNotThrow(function () {
65+
mod.destroy();
66+
}, "should not throw when calling Module#destroy");
67+
test.end();
68+
});
69+
70+
test("loading a text (wat) module", function (test) {
71+
var str = fs.readFileSync(__dirname + "/assembly/module.wat").toString();
72+
var mod;
73+
test.doesNotThrow(function () {
74+
mod = wabt.parseWat("module.wat", str);
75+
});
76+
test.ok(mod && typeof mod.toBinary === "function", "should return a module");
77+
test.doesNotThrow(function () {
78+
mod.destroy();
79+
}, "should not throw when calling Module#destroy");
80+
test.end();
81+
});
82+
83+
test("loading a text (wat) module with features", function (test) {
84+
var str = fs.readFileSync(__dirname + "/assembly/module-features.wat").toString();
85+
var mod;
86+
test.doesNotThrow(function () {
87+
mod = wabt.parseWat("module-features.wat", str);
88+
});
89+
test.ok(mod && typeof mod.toBinary === "function", "should return a module");
90+
test.doesNotThrow(function () {
91+
mod.destroy();
92+
}, "should not throw when calling Module#destroy");
93+
test.end();
94+
});
95+
96+
});

0 commit comments

Comments
 (0)