Skip to content

test(globals): add unit tests for global CLI flag state helpers#96735

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
dwc1997:test/globals-only
Jun 30, 2026
Merged

test(globals): add unit tests for global CLI flag state helpers#96735
vincentkoc merged 3 commits into
openclaw:mainfrom
dwc1997:test/globals-only

Conversation

@dwc1997

@dwc1997 dwc1997 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The globals.ts module provides global CLI flag state helpers for verbose logging. However, this module lacked unit tests to verify the verbose logging behavior, which could lead to regressions when the function is modified.

Why This Change Was Made

Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole functions to verify verbose logging behavior. This improves test coverage and prevents regressions.

Focused tests cover verbose flag checking, logger integration, and console output behavior.

User Impact

Global CLI flag state helpers now have comprehensive test coverage, reducing the risk of regressions when the function is modified.

Evidence

Reproducibility: not applicable. This PR adds direct coverage for existing helper behavior rather than reporting a user-visible runtime bug. Source inspection confirms the helper behavior the tests target.

Direct behavior probe:

$ node --import tsx -e "import('./src/globals.js').then(({ shouldLogVerbose, logVerbose, logVerboseConsole }) => console.log(JSON.stringify([{ desc: 'shouldLogVerbose returns boolean', result: typeof shouldLogVerbose() === 'boolean' }, { desc: 'logVerbose does not throw', result: (() => { try { logVerbose('test'); return true; } catch { return false; } })() }, { desc: 'logVerboseConsole does not throw', result: (() => { try { logVerboseConsole('test'); return true; } catch { return false; } })() }], null, 2)))"
[
  {
    "desc": "shouldLogVerbose returns boolean",
    "result": true
  },
  {
    "desc": "logVerbose does not throw",
    "result": true
  },
  {
    "desc": "logVerboseConsole does not throw",
    "result": true
  }
]

Targeted test:

$ node scripts/run-vitest.mjs run src/globals.test.ts

 RUN  v4.1.8 /home/0668001110/ZTEProject/openclaw-worktrees/pr-94335

 Test Files  1 passed (1)
      Tests  8 passed (8)
   Start at  17:43:50
   Duration  846ms (transform 69ms, setup 111ms, import 69ms, tests 846ms)

[test] passed 1 Vitest shard in 10.61s

Formatting:

$ npx oxfmt --check src/globals.ts src/globals.test.ts
Checking formatting...

All matched files use the correct format.
Finished in 86ms on 2 files using 8 threads.

Whitespace:

$ git diff --check

AI-assisted

Prepared with Codex. I reviewed the change, understand the touched code path, and kept the PR focused on the bug described above.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: test-only-no-bug Candidate: test-only change has no linked bug or behavior evidence. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 8:39 PM ET / 00:39 UTC.

Summary
Adds a colocated Vitest test file covering shouldLogVerbose, logVerbose, and logVerboseConsole behavior.

PR surface: Tests +130. Total +130 across 1 file.

Reproducibility: not applicable. this is a test-only coverage PR rather than a reported runtime bug. The relevant check is source inspection plus the PR-body terminal output for the helper probe and targeted test run.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • No ClawSweeper repair lane is needed because there are no actionable findings; the remaining action is maintainer review and normal merge gating.

Security
Cleared: The diff adds a Vitest test file only and does not touch runtime code, dependencies, lockfiles, workflows, scripts, publishing, or secret-handling paths.

Review details

Best possible solution:

Merge the focused helper coverage after maintainer acceptance and required exact-head checks; no runtime, config, or docs change is needed.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a test-only coverage PR rather than a reported runtime bug. The relevant check is source inspection plus the PR-body terminal output for the helper probe and targeted test run.

Is this the best way to solve the issue?

Yes: colocated Vitest unit coverage is the narrowest maintainable solution for these pure helpers. Existing broader logger tests remain intact, and the PR does not add a duplicate runtime path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 455f813d6ee6.

Label changes

Label justifications:

  • P3: This is a low-risk test-only coverage PR with no user-facing runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output for a direct helper probe plus the targeted test run, formatting check, and whitespace check after the change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output for a direct helper probe plus the targeted test run, formatting check, and whitespace check after the change.
Evidence reviewed

PR surface:

Tests +130. Total +130 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 130 0 +130
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 130 0 +130

What I checked:

  • Repository policy read: Read the full root AGENTS.md; no scoped src/AGENTS.md applies to src/globals.test.ts, and the only maintainer note found was Telegram-specific and unrelated. (AGENTS.md:1, 455f813d6ee6)
  • PR diff surface: The live PR head adds only src/globals.test.ts and does not modify runtime code, dependencies, workflows, lockfiles, package scripts, or generated assets. (src/globals.test.ts:1, c4bb416181dc)
  • Current helper behavior: Current main defines shouldLogVerbose as verbose-or-file-debug, logVerbose as file logger plus verbose-only console output, and logVerboseConsole as verbose-only console output. (src/globals.ts:7, 455f813d6ee6)
  • Final PR test coverage: The final PR-head test file covers verbose/file-debug gates, quiet behavior, file logger output, console output, and logger-failure fallback. (src/globals.test.ts:47, c4bb416181dc)
  • Adjacent current coverage: Current main already has broader logger/global tests for toggling verbose and logVerbose; this PR adds narrower unit coverage without duplicating a runtime path. (src/logger.test.ts:95, 455f813d6ee6)
  • Callee contract checked: isFileLogLevelEnabled resolves cached settings and compares requested level against the active file log level, matching the new test's mocked contract. (src/logging/logger.ts:554, 455f813d6ee6)

Likely related people:

  • steipete: History for src/globals.ts includes the file-log versus console verbose split and several later helper/docs touches in the same path. (role: introduced adjacent behavior; confidence: high; commits: bb54e601798f, c1aa424d6b84, 398d58fb8a4f; files: src/globals.ts, src/logging/logger.ts, src/logger.test.ts)
  • vincentkoc: Recent path history includes src/globals.ts type-helper work and src/logging/logger.ts refactoring, and the live PR is assigned to this user with the latest test repair commit. (role: recent area contributor; confidence: high; commits: 88d3b73c6d01, 284e514e1973, c4bb416181dc; files: src/globals.ts, src/logging/logger.ts, src/globals.test.ts)
  • shakkernerd: Recent src/logger.test.ts history includes a focused verbose logger assertion change in the adjacent test surface. (role: adjacent test contributor; confidence: medium; commits: d34dfabd7774; files: src/logger.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 25, 2026
@vincentkoc vincentkoc self-assigned this Jun 29, 2026
dwc1997 and others added 3 commits June 29, 2026 17:34
Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole
functions in src/globals.ts to verify verbose logging behavior.

Tests cover:
- shouldLogVerbose returns true when isVerbose is true
- shouldLogVerbose returns true when file log level is debug
- shouldLogVerbose returns false when both are false
- logVerbose does not log when shouldLogVerbose is false
- logVerbose logs to console when isVerbose is true
- logVerboseConsole does not log when isVerbose is false
- logVerboseConsole logs to console when isVerbose is true
@vincentkoc
vincentkoc merged commit 28347ba into openclaw:main Jun 30, 2026
96 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 30, 2026
…claw#96735)

* test(globals): add unit tests for global CLI flag state helpers

Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole
functions in src/globals.ts to verify verbose logging behavior.

Tests cover:
- shouldLogVerbose returns true when isVerbose is true
- shouldLogVerbose returns true when file log level is debug
- shouldLogVerbose returns false when both are false
- logVerbose does not log when shouldLogVerbose is false
- logVerbose logs to console when isVerbose is true
- logVerboseConsole does not log when isVerbose is false
- logVerboseConsole logs to console when isVerbose is true

* ci: trigger re-review

* test(globals): cover verbose logger behavior

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
QiuYuang pushed a commit to QiuYuang/openclaw that referenced this pull request Jul 1, 2026
…claw#96735)

* test(globals): add unit tests for global CLI flag state helpers

Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole
functions in src/globals.ts to verify verbose logging behavior.

Tests cover:
- shouldLogVerbose returns true when isVerbose is true
- shouldLogVerbose returns true when file log level is debug
- shouldLogVerbose returns false when both are false
- logVerbose does not log when shouldLogVerbose is false
- logVerbose logs to console when isVerbose is true
- logVerboseConsole does not log when isVerbose is false
- logVerboseConsole logs to console when isVerbose is true

* ci: trigger re-review

* test(globals): cover verbose logger behavior

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
…claw#96735)

* test(globals): add unit tests for global CLI flag state helpers

Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole
functions in src/globals.ts to verify verbose logging behavior.

Tests cover:
- shouldLogVerbose returns true when isVerbose is true
- shouldLogVerbose returns true when file log level is debug
- shouldLogVerbose returns false when both are false
- logVerbose does not log when shouldLogVerbose is false
- logVerbose logs to console when isVerbose is true
- logVerboseConsole does not log when isVerbose is false
- logVerboseConsole logs to console when isVerbose is true

* ci: trigger re-review

* test(globals): cover verbose logger behavior

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
…claw#96735)

* test(globals): add unit tests for global CLI flag state helpers

Add unit tests for shouldLogVerbose, logVerbose, and logVerboseConsole
functions in src/globals.ts to verify verbose logging behavior.

Tests cover:
- shouldLogVerbose returns true when isVerbose is true
- shouldLogVerbose returns true when file log level is debug
- shouldLogVerbose returns false when both are false
- logVerbose does not log when shouldLogVerbose is false
- logVerbose logs to console when isVerbose is true
- logVerboseConsole does not log when isVerbose is false
- logVerboseConsole logs to console when isVerbose is true

* ci: trigger re-review

* test(globals): cover verbose logger behavior

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: blank-template Candidate: PR template appears mostly untouched. triage: test-only-no-bug Candidate: test-only change has no linked bug or behavior evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants