Skip to content

Commit 54213e7

Browse files
xuiocodex
andcommitted
Quiet unit tests in CI
Co-Authored-By: OpenAI Codex <noreply@openai.com>
1 parent 3d2f957 commit 54213e7

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"test:claude-real-codex": "node test/claude-real-codex.mjs",
4848
"test:claude-real-session": "node test/claude-real-session.mjs",
4949
"test:real-soak": "node test/real-soak.mjs",
50-
"test:ci": "npm run build && npm run test:plugin-manifest && npm test && npm run test:stdio-shutdown && npm run smoke:mcp && npm run test:reliability && npm run test:stress && npm run test:progress && npm run test:advanced && npm run test:dev-link",
50+
"test:ci": "npm run build && npm run test:plugin-manifest && env CODEX_SUBAGENTS_LOG_LEVEL=${CODEX_SUBAGENTS_LOG_LEVEL:-silent} npm test && npm run test:stdio-shutdown && npm run smoke:mcp && npm run test:reliability && npm run test:stress && npm run test:progress && npm run test:advanced && npm run test:dev-link",
5151
"test:comprehensive": "npm run build && npm test && npm run test:stdio-shutdown && npm run smoke:mcp && npm run test:reliability && npm run test:stress && npm run test:progress && npm run test:advanced && npm run test:codex-runtime && npm run test:app-server-contract && npm run test:real-matrix && npm run validate:plugin && npm run test:claude-desktop",
5252
"test:claude-desktop": "node test/claude-desktop-cli.mjs"
5353
},

test/logging.test.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ import {
1313
summarizeRawTrafficForLog,
1414
} from "../src/logging.js";
1515

16+
const logEnvKeys = [
17+
"CODEX_SUBAGENTS_LOG_PROFILE",
18+
"CODEX_SUBAGENTS_LOG_LEVEL",
19+
"CODEX_SUBAGENTS_LOG_RAW_REDACT",
20+
"CODEX_SUBAGENTS_LOG_MAX_STRING_CHARS",
21+
"CODEX_SUBAGENTS_DEBUG_BUNDLE_DIR",
22+
"CODEX_SUBAGENTS_LOG_FILE",
23+
"CODEX_SUBAGENTS_LOG_FILE_MAX_BYTES",
24+
] as const;
25+
26+
const originalLogEnv = Object.fromEntries(logEnvKeys.map((key) => [key, process.env[key]]));
27+
1628
afterEach(() => {
1729
resetLogWriterForTest();
18-
delete process.env.CODEX_SUBAGENTS_LOG_PROFILE;
19-
delete process.env.CODEX_SUBAGENTS_LOG_LEVEL;
20-
delete process.env.CODEX_SUBAGENTS_LOG_RAW_REDACT;
21-
delete process.env.CODEX_SUBAGENTS_LOG_MAX_STRING_CHARS;
22-
delete process.env.CODEX_SUBAGENTS_DEBUG_BUNDLE_DIR;
23-
delete process.env.CODEX_SUBAGENTS_LOG_FILE;
24-
delete process.env.CODEX_SUBAGENTS_LOG_FILE_MAX_BYTES;
30+
for (const key of logEnvKeys) {
31+
const value = originalLogEnv[key];
32+
if (value === undefined) delete process.env[key];
33+
else process.env[key] = value;
34+
}
2535
});
2636

2737
describe("logging", () => {
@@ -32,6 +42,7 @@ describe("logging", () => {
3242
});
3343

3444
it("logs raw MCP traffic without redacting prompt-like values", () => {
45+
process.env.CODEX_SUBAGENTS_LOG_LEVEL = "debug";
3546
const lines: string[] = [];
3647
setLogWriterForTest((line) => lines.push(line));
3748

@@ -57,6 +68,7 @@ describe("logging", () => {
5768
});
5869

5970
it("redacts raw traffic by default in production logging profile", () => {
71+
delete process.env.CODEX_SUBAGENTS_LOG_LEVEL;
6072
process.env.CODEX_SUBAGENTS_LOG_PROFILE = "production";
6173
const lines: string[] = [];
6274
setLogWriterForTest((line) => lines.push(line));
@@ -85,6 +97,7 @@ describe("logging", () => {
8597
it("writes log files with owner-only permissions", async () => {
8698
const dir = await mkdtemp(path.join(os.tmpdir(), "codex-subagents-logs-"));
8799
const logFile = path.join(dir, "server.log");
100+
process.env.CODEX_SUBAGENTS_LOG_LEVEL = "info";
88101
process.env.CODEX_SUBAGENTS_LOG_FILE = logFile;
89102

90103
logger.info("test.log_file_mode", { ok: true });
@@ -96,6 +109,7 @@ describe("logging", () => {
96109
it("keeps rotated log files owner-only", async () => {
97110
const dir = await mkdtemp(path.join(os.tmpdir(), "codex-subagents-logs-"));
98111
const logFile = path.join(dir, "server.log");
112+
process.env.CODEX_SUBAGENTS_LOG_LEVEL = "info";
99113
process.env.CODEX_SUBAGENTS_LOG_FILE = logFile;
100114
process.env.CODEX_SUBAGENTS_LOG_FILE_MAX_BYTES = "10";
101115
await writeFile(logFile, "x".repeat(20), "utf8");

0 commit comments

Comments
 (0)