OCaml server commands: - vm-trace: step-by-step bytecode execution trace (opcode, stack, depth) - bytecode-inspect: disassemble compiled function (opcodes, constants, arity) - deps-check: strict symbol resolution (resolved vs unresolved symbols) - prim-check: verify CALL_PRIM opcodes match real primitives Scripts: - hosts/ocaml/browser/test_boot.sh: WASM boot test in Node.js - scripts/sx-build-all.sh: full pipeline (OCaml + JS + tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
1.5 KiB
Bash
Executable File
31 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test WASM boot in Node.js — verifies the compiled sx_browser.bc.js loads
|
|
# without errors by providing minimal DOM/browser API stubs.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/../../.."
|
|
|
|
node -e "
|
|
global.window = global;
|
|
global.document = { createElement: () => ({style:{},setAttribute:()=>{},appendChild:()=>{},children:[]}), createDocumentFragment: () => ({appendChild:()=>{},children:[],childNodes:[]}), head:{appendChild:()=>{}}, body:{appendChild:()=>{}}, querySelector:()=>null, querySelectorAll:()=>[], createTextNode:(s)=>({textContent:s}), addEventListener:()=>{}, createComment:(s)=>({textContent:s||''}) };
|
|
global.localStorage = {getItem:()=>null,setItem:()=>{},removeItem:()=>{}};
|
|
global.CustomEvent = class { constructor(n,o){this.type=n;this.detail=(o||{}).detail||{}} };
|
|
global.MutationObserver = class { observe(){} disconnect(){} };
|
|
global.requestIdleCallback = (fn) => setTimeout(fn,0);
|
|
global.matchMedia = () => ({matches:false});
|
|
global.navigator = {serviceWorker:{register:()=>Promise.resolve()}};
|
|
global.location = {href:'',pathname:'/',hostname:'localhost'};
|
|
global.history = {pushState:()=>{},replaceState:()=>{}};
|
|
global.fetch = () => Promise.resolve({ok:true,text:()=>Promise.resolve('')});
|
|
global.setTimeout = setTimeout;
|
|
global.clearTimeout = clearTimeout;
|
|
try {
|
|
require('./shared/static/wasm/sx_browser.bc.js');
|
|
console.log('WASM boot: OK');
|
|
} catch(e) {
|
|
console.error('WASM boot: FAILED');
|
|
console.error(e.message);
|
|
process.exit(1);
|
|
}
|
|
"
|