123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- var waitFor;
- if (typeof drainJobQueue !== 'undefined') {
- waitFor = function waitFor(p) { drainJobQueue(); return p; };
- } else {
- // JSC and V8 will drain promises before exiting and don't require a
- // specific waiter.
- waitFor = function waitFor(p) { return p; };
- }
- var args;
- if (typeof scriptArgs !== 'undefined') {
- args = scriptArgs;
- } else if (typeof arguments !== 'undefined') {
- args = arguments;
- } else {
- // No script arguments available
- args = [];
- }
- var log = print;
- var logErr = print;
- if (typeof printErr !== 'undefined') {
- logErr = printErr;
- }
- var _exit;
- if (typeof quit !== 'undefined') {
- _exit = quit.bind(this);
- } else if (typeof testRunner !== 'undefined') {
- _exit = testRunner.quit.bind(testRunner);
- }
- // V8 treats multiple arguments as files, unless -- is given, but
- // SpiderMonkey doesn't treat -- specially. This is a hack to allow
- // for -- on SpiderMonkey.
- if (args[0] == '--') {
- args.shift();
- }
- if (args.length < 3) {
- logErr('usage: await-call.js REFLECT_JS_DIR REFLECT_WASM_DIR PROC.WASM ARG.WASM...');
- _exit(1);
- }
- async function runTest(call, opts) {
- try {
- let [procFile, ...argFiles] = call;
- let [proc] = await Scheme.load_main(procFile, opts);
- let argPromises =
- argFiles.map(file => proc.reflector.load_extension(file, opts));
- let args = [];
- for (let p of argPromises) {
- let [arg] = await p;
- args.push(arg);
- }
- log(repr(await proc.call_async(...args)));
- } catch (e) {
- log(`error: ${e} (${e.stack})`);
- _exit(1);
- }
- }
- var [reflect_js_dir, reflect_wasm_dir, ...test_call] = args;
- load(`${reflect_js_dir}/reflect.js`);
- waitFor(runTest(test_call, {reflect_wasm_dir}));
|