惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
腾讯CDC
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园_首页
D
DataBreaches.Net
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
月光博客
月光博客
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Vercel News
Vercel News
WordPress大学
WordPress大学
J
Java Code Geeks
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: share process platform spy helper · openclaw/opencl...
vincentkoc · 2026-05-17 · via Recent Commits to openclaw:main

@@ -1,5 +1,6 @@

11

import fsSync from "node:fs";

22

import { afterEach, describe, expect, it, vi } from "vitest";

3+

import { withMockedPlatform } from "../test-utils/vitest-spies.js";

34

import { getProcessStartTime, isPidAlive, isPidDefinitelyDead } from "./pid-alive.js";

4556

afterEach(() => {

@@ -17,30 +18,6 @@ function mockProcReads(entries: Record<string, string>) {

1718

});

1819

}

192020-

async function withLinuxProcessPlatform<T>(run: () => Promise<T>): Promise<T> {

21-

return withProcessPlatform("linux", run);

22-

}

23-24-

async function withProcessPlatform<T>(

25-

platform: NodeJS.Platform,

26-

run: () => Promise<T>,

27-

): Promise<T> {

28-

const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");

29-

if (!originalPlatformDescriptor) {

30-

throw new Error("missing process.platform descriptor");

31-

}

32-

Object.defineProperty(process, "platform", {

33-

...originalPlatformDescriptor,

34-

value: platform,

35-

});

36-

try {

37-

return await run();

38-

} finally {

39-

Object.defineProperty(process, "platform", originalPlatformDescriptor);

40-

vi.restoreAllMocks();

41-

}

42-

}

43-4421

describe("isPidAlive", () => {

4522

it("returns true for the current running process", () => {

4623

expect(isPidAlive(process.pid)).toBe(true);

@@ -64,7 +41,7 @@ describe("isPidAlive", () => {

6441

mockProcReads({

6542

[`/proc/${zombiePid}/status`]: `Name:\tnode\nUmask:\t0022\nState:\tZ (zombie)\nTgid:\t${zombiePid}\nPid:\t${zombiePid}\n`,

6643

});

67-

await withLinuxProcessPlatform(async () => {

44+

await withMockedPlatform("linux", async () => {

6845

expect(isPidAlive(zombiePid)).toBe(false);

6946

});

7047

});

@@ -75,7 +52,7 @@ describe("isPidAlive", () => {

7552

});

7653

const killSpy = vi.spyOn(process, "kill").mockImplementation(() => true);

775478-

await withLinuxProcessPlatform(async () => {

55+

await withMockedPlatform("linux", async () => {

7956

expect(isPidAlive(42)).toBe(true);

8057

});

8158

@@ -120,7 +97,7 @@ describe("isPidDefinitelyDead", () => {

12097

[`/proc/${zombiePid}/status`]: `Name:\tnode\nUmask:\t0022\nState:\tZ (zombie)\nTgid:\t${zombiePid}\nPid:\t${zombiePid}\n`,

12198

});

12299123-

await withLinuxProcessPlatform(async () => {

100+

await withMockedPlatform("linux", async () => {

124101

expect(isPidDefinitelyDead(zombiePid)).toBe(true);

125102

});

126103

});

@@ -132,7 +109,7 @@ describe("isPidDefinitelyDead", () => {

132109

[`/proc/${livePid}/status`]: `Name:\tnode\nUmask:\t0022\nState:\tS (sleeping)\nTgid:\t${livePid}\nPid:\t${livePid}\n`,

133110

});

134111135-

await withLinuxProcessPlatform(async () => {

112+

await withMockedPlatform("linux", async () => {

136113

expect(isPidDefinitelyDead(livePid)).toBe(false);

137114

});

138115

});

@@ -152,7 +129,7 @@ describe("getProcessStartTime", () => {

152129

"/proc/46/stat": `${fakeStatPrefix}1.5${fakeStatSuffix}`,

153130

});

154131155-

await withLinuxProcessPlatform(async () => {

132+

await withMockedPlatform("linux", async () => {

156133

expect(getProcessStartTime(process.pid)).toBe(98765);

157134

expect(getProcessStartTime(42)).toBe(55555);

158135

expect(getProcessStartTime(43)).toBeNull();

@@ -163,7 +140,7 @@ describe("getProcessStartTime", () => {

163140

});

164141165142

it("returns null on non-Linux platforms", () => {

166-

return withProcessPlatform("darwin", async () => {

143+

return withMockedPlatform("darwin", async () => {

167144

expect(getProcessStartTime(process.pid)).toBeNull();

168145

});

169146

});