Skip to content

Commit b5f9c47

Browse files
committed
deps: update wasi-testsuite to latest prod/testsuite-all
1 parent 37fa400 commit b5f9c47

File tree

6 files changed

+102
-26
lines changed

6 files changed

+102
-26
lines changed

test/adapters/browser/run-wasi.mjs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,28 @@ import { chromium } from "playwright"
66
import { parseArgs } from "../shared/parseArgs.mjs"
77
import { walkFs } from "../shared/walkFs.mjs"
88

9+
function parseDirSpec(dirSpec) {
10+
const separator = dirSpec.indexOf("::");
11+
if (separator === -1) {
12+
return { host: dirSpec, guest: dirSpec };
13+
}
14+
const host = dirSpec.slice(0, separator);
15+
const guest = dirSpec.slice(separator + 2) || ".";
16+
return { host, guest };
17+
}
18+
919
async function derivePreopens(dirs) {
1020
const preopens = [];
11-
for (let dir of dirs) {
12-
const contents = await walkFs(dir, (name, entry, out) => {
21+
for (const dirSpec of dirs) {
22+
const { host, guest } = parseDirSpec(dirSpec);
23+
const contents = await walkFs(host, (name, entry, out) => {
1324
if (entry.kind === "file") {
1425
// Convert buffer to array to make it serializable.
1526
entry.buffer = Array.from(entry.buffer);
1627
}
1728
return { ...out, [name]: entry };
1829
}, () => {});
19-
preopens.push({ dir, contents });
30+
preopens.push({ dir: guest, contents });
2031
}
2132
return preopens;
2233
}
@@ -58,7 +69,12 @@ async function configureRoutes(context, harnessURL) {
5869
const content = await fs.readFile(path.join(projectDir, relativePath));
5970
route.fulfill({
6071
status: 200,
61-
contentType: 'application/javascript',
72+
contentType:
73+
{
74+
".wasm": "application/wasm",
75+
".json": "application/json",
76+
".js": "application/javascript",
77+
}[path.extname(pathname)] || "application/octet-stream",
6278
body: content,
6379
});
6480
});

test/adapters/node/run-wasi.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ class NodeStdout extends Fd {
3333
}
3434
}
3535

36+
function parseDirSpec(dirSpec) {
37+
const separator = dirSpec.indexOf("::");
38+
if (separator === -1) {
39+
return { host: dirSpec, guest: dirSpec };
40+
}
41+
const host = dirSpec.slice(0, separator);
42+
const guest = dirSpec.slice(separator + 2) || ".";
43+
return { host, guest };
44+
}
45+
3646
async function derivePreopens(dirs) {
3747
const preopens = [];
38-
for (let dir of dirs) {
39-
const contents = await walkFs(dir, (name, entry, out) => {
48+
for (const dirSpec of dirs) {
49+
const { host, guest } = parseDirSpec(dirSpec);
50+
const contents = await walkFs(host, (name, entry, out) => {
4051
switch (entry.kind) {
4152
case "dir":
4253
entry = new Directory(entry.contents);
@@ -50,7 +61,7 @@ async function derivePreopens(dirs) {
5061
out.set(name, entry);
5162
return out;
5263
}, () => new Map())
53-
const preopen = new PreopenDirectory(dir, contents);
64+
const preopen = new PreopenDirectory(guest, contents);
5465
preopens.push(preopen);
5566
}
5667
return preopens;

test/adapters/shared/adapter.py

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
1-
import subprocess
2-
import pathlib
3-
import sys
1+
import json
42
import os
3+
import shlex
4+
from functools import lru_cache
5+
from pathlib import Path
6+
from typing import Dict, List, Tuple
57

6-
run_wasi_mjs = pathlib.Path(__file__).parent / "run-wasi.mjs"
7-
args = sys.argv[1:]
8-
cmd = ["node", str(run_wasi_mjs)] + args
9-
if os.environ.get("VERBOSE_ADAPTER") is not None:
10-
print(" ".join(map(lambda x: f"'{x}'", cmd)))
8+
def _adapter_dir() -> Path:
9+
spec = globals().get("__spec__")
10+
if spec is not None and getattr(spec, "origin", None):
11+
return Path(spec.origin).parent
12+
return Path(__file__).parent
1113

12-
result = subprocess.run(cmd, check=False)
13-
sys.exit(result.returncode)
14+
15+
_ADAPTER_DIR = _adapter_dir()
16+
17+
18+
@lru_cache(maxsize=1)
19+
def _package_metadata() -> Dict[str, str]:
20+
with (_ADAPTER_DIR.parents[2] / "package.json").open(encoding="utf-8") as pkg_file:
21+
return json.load(pkg_file)
22+
23+
24+
def get_name() -> str:
25+
return f"{_package_metadata()['name']} ({_ADAPTER_DIR.name})"
26+
27+
28+
def get_version() -> str:
29+
return _package_metadata()["version"]
30+
31+
32+
def get_wasi_versions() -> List[str]:
33+
return ["wasm32-wasip1"]
34+
35+
36+
def compute_argv(test_path: str,
37+
args: List[str],
38+
env: Dict[str, str],
39+
dirs: List[Tuple[Path, str]],
40+
wasi_version: str) -> List[str]:
41+
if wasi_version != "wasm32-wasip1":
42+
raise RuntimeError(f"unsupported WASI version: {wasi_version}")
43+
44+
node_cmd = shlex.split(os.environ.get("NODE", "node"))
45+
run_wasi = _ADAPTER_DIR / "run-wasi.mjs"
46+
argv = node_cmd + [str(run_wasi), f"--test-file={test_path}"]
47+
48+
for arg in args:
49+
argv.extend(["--arg", arg])
50+
51+
for key, value in env.items():
52+
argv.extend(["--env", f"{key}={value}"])
53+
54+
for host, guest in dirs:
55+
argv.extend(["--dir", f"{os.fspath(host)}::{guest}"])
56+
57+
if os.environ.get("VERBOSE_ADAPTER"):
58+
print(" ".join(shlex.quote(component) for component in argv))
59+
60+
return argv

test/run-testsuite.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ if [ $# -gt 0 ]; then
1212
fi
1313

1414
python3 "$TESTSUITE_ROOT/test-runner/wasi_test_runner.py" \
15-
--test-suite "$TESTSUITE_ROOT/tests/assemblyscript/testsuite/" \
16-
"$TESTSUITE_ROOT/tests/c/testsuite/" \
17-
"$TESTSUITE_ROOT/tests/rust/testsuite/" \
15+
--test-suite "$TESTSUITE_ROOT/tests/assemblyscript/testsuite/wasm32-wasip1" \
16+
"$TESTSUITE_ROOT/tests/c/testsuite/wasm32-wasip1" \
17+
"$TESTSUITE_ROOT/tests/rust/testsuite/wasm32-wasip1" \
1818
--runtime-adapter "$TEST_DIR/adapters/$ADAPTER/adapter.py" \
1919
--exclude-filter "$TEST_DIR/skip.json" \
2020
$@

test/skip.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"WASI Assemblyscript tests": {
2+
"WASI Assemblyscript tests [wasm32-wasip1]": {
33
},
4-
"WASI C tests": {
4+
"WASI C tests [wasm32-wasip1]": {
55
"sock_shutdown-invalid_fd": "not implemented yet",
66
"stat-dev-ino": "fail",
77
"sock_shutdown-not_sock": "fail",
8-
"fdopendir-with-access": "fail"
8+
"fdopendir-with-access": "fail",
9+
"pwrite-with-append": "fail"
910
},
10-
"WASI Rust tests": {
11+
"WASI Rust tests [wasm32-wasip1]": {
1112
"path_exists": "fail",
1213
"fd_filestat_set": "fail",
1314
"symlink_create": "fail",
@@ -24,6 +25,7 @@
2425
"nofollow_errors": "fail",
2526
"path_open_preopen": "fail",
2627
"symlink_filestat": "fail",
27-
"symlink_loop": "fail"
28+
"symlink_loop": "fail",
29+
"fstflags_validate": "fail"
2830
}
2931
}

test/wasi-testsuite

Submodule wasi-testsuite updated 464 files

0 commit comments

Comments
 (0)