Files
fpv-rid-workbench/scripts/test-release.mjs
T
JiuContinent 4eaa88baeb ```
feat(protocol): Observation坐标字段可选化及协议v2扩展

- 将Observation中longitude/latitude/altitude_m/heading_deg改为Option类型,
  支持无位置信息的观测数据
- 新增DeviceTelemetry结构体承载设备遥测扩展字段(serial, mac, model, rssi,
  speed, vertical_speed, pressure_altitude, geometric_altitude, height_agl,
  pilot_position等)
- 新增LegacyObservation兼容结构体及From转换,保持旧接收器协议输入兼容
- PROTOCOL_VERSION从1升至2
- 新增coordinates()辅助方法统一提取有效坐标
- validate()适配Option类型,允许坐标字段同时缺失
- Store新增position_generation机制追踪位置可用性变化,确保合并帧间的
  位置丢失仍能正确断开轨迹
- geofence-map-adapter过滤无效坐标避免渲染异常
- 新增appearance.css外观主题系统,支持blue/graphite/white三套配色
```
2026-10-26 15:14:43 +08:00

20 lines
2.6 KiB
JavaScript

import {mkdtemp,cp,access} from 'node:fs/promises';
import {tmpdir} from 'node:os';
import path from 'node:path';
import {spawn} from 'node:child_process';
import assert from 'node:assert/strict';
const repo=path.resolve(import.meta.dirname,'..');const root=await mkdtemp(path.join(tmpdir(),'RID-便携验收-'));const app=path.join(root,'发布程序');
await cp(path.join(repo,'dist/FPV-RID-Rust'),app,{recursive:true});
let occupied=false;try{await fetch('http://127.0.0.1:8787/');occupied=true;}catch{}if(occupied)throw Error('8787 已被占用');
const exe=path.join(app,'fpv-rid-registry.exe');let output='';
const child=spawn(exe,[],{cwd:root,windowsHide:true,env:{...process.env,PATH:'C:\\Windows\\System32'},stdio:['ignore','pipe','pipe']});child.stdout.on('data',b=>output+=b);child.stderr.on('data',b=>output+=b);let spawnError;child.on('error',e=>spawnError=e);
try{
for(let i=0;i<150;i++){if(spawnError||child.exitCode!==null)throw Error(output||String(spawnError));try{if((await fetch('http://127.0.0.1:8787/api/records')).ok)break;}catch{}await new Promise(r=>setTimeout(r,100));}
await access(path.join(app,'registry/data/registry.sqlite'));await assert.rejects(access(path.join(root,'registry/data/registry.sqlite')));
await access(path.join(app,'maps/offline'));await assert.rejects(access(path.join(root,'maps/offline')));
const page=await fetch('http://127.0.0.1:8787/');assert.equal(page.status,200);assert.match(await page.text(),/bootstrap|rid-web-ui|wasm/);
const reopen=spawn(exe,[],{cwd:root,windowsHide:true,stdio:['ignore','pipe','pipe']});let reopenError='';reopen.stderr.on('data',b=>reopenError+=b);const reopenCode=await new Promise((resolve,reject)=>{reopen.on('exit',resolve);reopen.on('error',reject);});assert.equal(reopenCode,0,reopenError);assert.equal(child.exitCode,null);assert.equal((await fetch('http://127.0.0.1:8787/')).status,200);
const second=spawn(exe,['--data-root',path.join(root,'第二实例')],{windowsHide:true,stdio:['ignore','pipe','pipe']});let stderr='';second.stderr.on('data',b=>stderr+=b);const code=await new Promise((resolve,reject)=>{second.on('exit',resolve);second.on('error',reject);});assert.notEqual(code,0);assert.match(stderr,/8787/);await assert.rejects(access(path.join(root,'第二实例/registry/data/registry.sqlite')));
console.log(JSON.stringify({status:'PASS',root,scenarios:['published exe','Chinese install path','different working directory','automatic offline folder beside exe','no Node PATH','embedded webpage','reopen existing service','port conflict without new database']}));
}finally{if(child.exitCode===null&&!spawnError){const exit=new Promise(r=>child.once('exit',r));child.kill();await exit;}}