-
Notifications
You must be signed in to change notification settings - Fork 10
/
wasmrt.nimble
38 lines (33 loc) · 1.15 KB
/
wasmrt.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Package
version = "0.1.0"
author = "Yuriy Glukhov"
description = "Nim wasm runtime"
license = "MIT"
bin = @["wasmrt/wasm2html"]
# Dependencies
requires "zippy" # For wasm2html
import os, oswalkdir
proc buildExample(name: string, shouldFail = false) =
echo "Running test ", name, (if shouldFail: " [should fail]" else: "")
exec "nim c --out:tests/" & name & ".wasm tests/" & name
# exec "wasm-gc tests/" & name & ".wasm"
# exec "wasm2wat -o tests/" & name & ".wast tests/" & name & ".wasm"
if shouldFail:
var failed = false
try:
exec "node ./tests/runwasm.js ./tests/" & name & ".wasm"
except:
echo "Test failed as it should"
failed = true
assert(failed, "Test " & name & " should fail but did not")
else:
exec "node ./tests/runwasm.js tests/" & name & ".wasm"
task test, "Test":
for f in oswalkdir.walkDir("tests"):
# Compile all nim modules, except those starting with "t"
let sf = f.path.splitFile()
if sf.ext == ".nim":
if sf.name.startsWith("t_"):
buildExample(sf.name)
elif sf.name.startsWith("f_"):
buildExample(sf.name, shouldFail = true)