2 lines
2.5 KiB
JavaScript
2 lines
2.5 KiB
JavaScript
import assert from"node:assert/strict";import fs from"node:fs";import path from"node:path";import{createRequire}from"node:module";import{pathToFileURL}from"node:url";const root=path.resolve(path.dirname(new URL(import.meta.url).pathname),".."),fp=process.argv[2],build=path.resolve(process.argv[3]??path.join(root,"freecad-source/build-web/configure/bin"));const f=await import(pathToFileURL(path.resolve(fp))),e=await import(pathToFileURL(path.join(path.dirname(path.resolve(fp)),"facade-envelope.js")));globalThis.__dirname=`${build}${path.sep}`;globalThis.require=createRequire(import.meta.url);const l=await import(pathToFileURL(path.join(build,"FreeCADWebPartDesignRuntimeProbe.js"))),k=await l.default({wasmBinary:fs.readFileSync(path.join(build,"FreeCADWebPartDesignRuntimeProbe.wasm")),print:()=>{},printErr:()=>{}}),q=new e.FacadeSerialQueue();let active=0,maxActive=0;const d=(r,s=k)=>q.dispatch(r,async(p,signal)=>{active++;maxActive=Math.max(maxActive,active);try{return await f.handlePartDesignSave(p,signal,s)}finally{active--}});const success=await d(f.createPartDesignSaveRequest("pdn-act04-success")),err=await d(f.createPartDesignSaveRequest("pdn-act04-error",{...f.PARTDESIGN_SAVE_FIXTURE,path:"/tmp/Bad.FCStd"})),dup=await d(f.createPartDesignSaveRequest("pdn-act04-success")),cr=f.createPartDesignSaveRequest("pdn-act04-cancel"),cp=d(cr,new Promise(r=>setTimeout(()=>r(k),0))),ca=q.cancel(e.createCancel("pdn-cancel-msg",cr.requestId,"partdesign-save")),cancelled=await cp,after=await d(f.createPartDesignSaveRequest("pdn-act04-after"));assert.equal(success.kind,"result");assert.equal(success.result.volume,24);assert.equal(err.error.code,"invalid_path");assert.equal(dup.error.code,"duplicate_request");assert.equal(ca,true);assert.equal(cancelled.error.code,"cancelled");assert.deepEqual(after.result,success.result);assert.equal(maxActive,1);const report={schema:"freecad-web-p6-partdesign-action-04-facade/v1",taskId:"FW-P6-PDN-ACT-04-E",module:"PartDesign",action:"save/reopen",result:"pass",responses:{success,err,dup,cancelled,after},sequencing:{maxActive,requestCount:5,cancelAccepted:ca},schemaChecks:{noNativePointers:!JSON.stringify({success,err,dup,cancelled,after}).match(/pointer|native|handle/i)}};fs.writeFileSync(path.join(root,"docs/p6/partdesign-action-04-facade.json"),JSON.stringify(report,null,2)+"\n");fs.writeFileSync(path.join(root,"docs/freecad-p6-partdesign-action-04-e-facade.log"),JSON.stringify({result:"pass",maxActive,requests:5,cancelAccepted:ca})+"\n");console.log(JSON.stringify({result:"pass",maxActive,requests:5,cancelAccepted:ca}));
|