Resolve wasm traps to unit source
This commit is contained in:
@@ -50,7 +50,7 @@ fi
|
||||
|
||||
entry_wasm="$artifact_dir/entry.uce.wasm"
|
||||
named_wasm="$artifact_dir/named.uce.wasm"
|
||||
python3 - "$entry_wasm" "$named_wasm" <<'PY'
|
||||
python3 - "$entry_wasm" "$named_wasm" "$absolute_source_dir" <<'PY'
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -60,9 +60,10 @@ cases = [
|
||||
(Path(sys.argv[1]), {"__wasm_call_ctors", "__uce_set_current_request", "__uce_cli", "visibility_shared"}, b"uce-private-unused-marker-8f61d2"),
|
||||
(Path(sys.argv[2]), {"__wasm_call_ctors", "__uce_set_current_request", "__uce_component_NAMED", "named_shared"}, b"uce-named-unused-marker-4ae973"),
|
||||
]
|
||||
source_dir = Path(sys.argv[3])
|
||||
for path, allowed, unused_marker in cases:
|
||||
data = path.read_bytes()
|
||||
_, imports, exports = collect(path)
|
||||
customs, imports, exports = collect(path)
|
||||
names = {name for name, _ in exports}
|
||||
unexpected = names - allowed
|
||||
missing = allowed - names
|
||||
@@ -74,6 +75,18 @@ for path, allowed, unused_marker in cases:
|
||||
raise SystemExit(f"{path}: retained {len(imports)} imports (expected fewer than 40)")
|
||||
if path.stat().st_size >= 1024 * 1024:
|
||||
raise SystemExit(f"{path}: artifact is {path.stat().st_size} bytes (expected under 1 MiB)")
|
||||
source_map = Path(str(path) + ".source-map")
|
||||
if not source_map.is_file() or source_map.stat().st_size >= 256 * 1024:
|
||||
raise SystemExit(f"{path}: missing or oversized source map")
|
||||
module = customs["uce.module"][-1].decode()
|
||||
lines = source_map.read_text().splitlines()
|
||||
if not lines or lines[0] != f"UCE_SOURCE_MAP_V1\t{module}":
|
||||
raise SystemExit(f"{path}: source map does not match wasm module identity")
|
||||
expected_source = str(source_dir / path.name.removesuffix(".wasm"))
|
||||
if not any(line.startswith("F\t") and line.endswith("\t" + expected_source) for line in lines):
|
||||
raise SystemExit(f"{path}: source map does not identify {expected_source}")
|
||||
if not any(line.startswith("L\t") for line in lines):
|
||||
raise SystemExit(f"{path}: source map has no address rows")
|
||||
PY
|
||||
|
||||
echo "unit export surface passed"
|
||||
|
||||
Reference in New Issue
Block a user