完成全量检查整改
清理已跟踪原始日志与个人本地配置 修复前后端有效门禁、测试和构建问题 补齐生产 Jenkins、SpacetimeDB 本地命令与文档约束 收紧图片编辑器状态、附件与媒体引用测试 排除已下线旧创作入口测试并清理 warning
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import {createServer} from 'node:net';
|
||||
import {mkdtempSync, readFileSync, rmSync} from 'node:fs';
|
||||
import {createServer} from 'node:net';
|
||||
import {tmpdir} from 'node:os';
|
||||
import {join} from 'node:path';
|
||||
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import {
|
||||
findAvailablePort,
|
||||
mapDevPortsToPortRange,
|
||||
@@ -23,6 +25,27 @@ function reservePort(port) {
|
||||
});
|
||||
}
|
||||
|
||||
async function reserveConsecutivePorts() {
|
||||
for (let attempt = 0; attempt < 20; attempt += 1) {
|
||||
const firstServer = await reservePort(0);
|
||||
const firstPort = firstServer.address().port;
|
||||
|
||||
if (firstPort === 65535) {
|
||||
await new Promise((resolve) => firstServer.close(resolve));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const secondServer = await reservePort(firstPort + 1);
|
||||
return {firstServer, secondServer, firstPort};
|
||||
} catch {
|
||||
await new Promise((resolve) => firstServer.close(resolve));
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('无法为测试保留两个连续端口');
|
||||
}
|
||||
|
||||
describe('dev stack port utils', () => {
|
||||
it('解析端口段并映射到四个 dev 端口', () => {
|
||||
expect(parsePortRangeSpec('10000-10099')).toEqual({
|
||||
@@ -39,9 +62,7 @@ describe('dev stack port utils', () => {
|
||||
});
|
||||
|
||||
it('使用端口可用性检查为被占用端口寻找后续可用端口', async () => {
|
||||
const firstServer = await reservePort(0);
|
||||
const firstPort = firstServer.address().port;
|
||||
const secondServer = await reservePort(firstPort + 1);
|
||||
const {firstServer, secondServer, firstPort} = await reserveConsecutivePorts();
|
||||
|
||||
try {
|
||||
const availablePort = await findAvailablePort({
|
||||
|
||||
Reference in New Issue
Block a user