Skip to content

Commit

Permalink
ci: revert test/node/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
G4Vi committed Jul 31, 2024
1 parent 57b159d commit fcf895a
Showing 1 changed file with 20 additions and 53 deletions.
73 changes: 20 additions & 53 deletions js/packages/observe-sdk-stdout/test/node/index.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,28 @@
const fs = require("fs");
const { WASI } = require("wasi");
const { StdOutAdapter } = require("@dylibso/observe-sdk-stdout");
//const { StdOutAdapter } = require("../../dist/cjs/index.js");
const { env, argv } = require('node:process')

const bytes = fs.readFileSync("../../../observe-api/test/cxx_guest_2.wasm");
const wasi = new WASI({
version: 'preview1',
args: argv.slice(1),
env,
});

// old (verbose) api
{
const wasi = new WASI({
version: 'preview1',
args: argv.slice(1),
env,
});
const adapter = new StdOutAdapter();
adapter.start(bytes, {
spanFilter: {
minDurationMicroseconds: 0,
}
}).then((traceContext) => {
const module = new WebAssembly.Module(bytes);

WebAssembly.instantiate(module, {
...wasi.getImportObject(),
...traceContext.getImportObject(),
}).then((instance) => {
traceContext.initSpanEnter(instance.exports.memory.buffer);
wasi.start(instance);
traceContext.stop();
});
});
}
const adapter = new StdOutAdapter();
const bytes = fs.readFileSync("../../test-data/test.c.instr.wasm");
adapter.start(bytes, {
spanFilter: {
minDurationMicroseconds: 0,
}
}).then((traceContext) => {
const module = new WebAssembly.Module(bytes);

// new API using instantiateWasm
// SetTimeout as temporary hack as demangling multiple modules at the same time fails:
// TypeError: wasm.__wbindgen_add_to_stack_pointer is not a function
{
const wasi = new WASI({
version: 'preview1',
args: argv.slice(1),
env,
WebAssembly.instantiate(module, {
...wasi.getImportObject(),
...traceContext.getImportObject(),
}).then((instance) => {
wasi.start(instance);
traceContext.stop();
});
const adapter = new StdOutAdapter();
setTimeout(() => {
adapter.start(bytes, {
spanFilter: {
minDurationMicroseconds: 0,
},
instantiateWasm: async (module, traceContext) => {
return WebAssembly.instantiate(module, {
...wasi.getImportObject(),
...traceContext.getImportObject(),
});
}
}).then(({ collector: traceContext, instance }) => {
wasi.start(instance);
traceContext.stop()
});
}, 5000);
}
});

0 comments on commit fcf895a

Please sign in to comment.