Skip to content

Commit 39ddb7b

Browse files
byapparovclaude
andcommitted
test(flag): cover HeadlessRun directly now that todo gating is gone (#182)
HeadlessRun stays as the headless-run signal (#152, #165). Its in-memory, not-from-environment contract was previously asserted only through the removed todowrite gating, so test it on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ec034c8 commit 39ddb7b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { afterEach, describe, expect, test } from "bun:test"
2+
import { HeadlessRun } from "../../src/flag/headless-run"
3+
4+
describe("HeadlessRun", () => {
5+
afterEach(() => {
6+
HeadlessRun.disable()
7+
delete process.env.AICTRL_HEADLESS_RUN
8+
})
9+
10+
test("is off until the run command enables it, and off again once disabled", () => {
11+
expect(HeadlessRun.enabled()).toBe(false)
12+
HeadlessRun.enable()
13+
expect(HeadlessRun.enabled()).toBe(true)
14+
HeadlessRun.disable()
15+
expect(HeadlessRun.enabled()).toBe(false)
16+
})
17+
18+
test("the environment cannot mark a process as a headless run", () => {
19+
// A run's child processes and stray shell exports must not inherit the mark.
20+
process.env.AICTRL_HEADLESS_RUN = "true"
21+
expect(HeadlessRun.enabled()).toBe(false)
22+
})
23+
})

0 commit comments

Comments
 (0)