Files
claude-mode/tests/cli/test_doctor.sh
T
smoidoandClaude Opus 5 51e42823d1 Tests, licence, and the tooling to keep the repo consistent
A test suite with no dependencies beyond bash and the Python standard
library, run by one command:

  scripts/test.sh                    (or: make test)
  scripts/test.sh --windows [host]   adds the PowerShell suite over SSH

- tests/static.sh: script syntax, JSON validity, VERSION against the widget
  manifest and CHANGELOG, providers.json against the kinds, probes and checks
  the code implements (and ids that would shadow a command), qmllint and
  shellcheck when installed.
- tests/python: unit tests for cm-json.py - providers and the column contract
  bash depends on, the original three scaffolds byte for byte, every
  catalogue parser and the cache, session scan/dismiss/repair, rename,
  defaults, health, the cost guard.
- tests/cli: the CLI in a sandbox with its own HOME, CM_ROOT,
  CLAUDE_CONFIG_DIR and a file-only vault, against fake Ollama, LM Studio,
  keyed-gateway and proxy servers - preflight, presets, models, doctor, a real
  switch, sessions, and the key helper under a rename race.
- tests/windows: the same idea on a Windows host, with USERPROFILE pointed at
  a temp folder so the real install is never touched.

Also: MIT licence, CHANGELOG.md reconstructed from history, .editorconfig and
.gitattributes pinning LF everywhere (what the tree already is), and
scripts/bump-version.sh, since the version lives in two files and drifted
once before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:42:38 +03:00

28 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# doctor on a server provider: model ids against the catalogue, and Ollama's
# server-side context window.
. "$(dirname "$0")/../lib.sh"
start_fake
ready_preset ollama "$OLLAMA_URL"
set_state ollama ollama
run_cm doctor
expect_out "Ollama reachable at $OLLAMA_URL" 'the server is found'
expect_out 'opus qwen3-coder [30.5B Q4_K_M]' 'a bare name matches its :latest tag'
expect_no_out 'NOT available' 'no model is reported missing'
expect_out 'loaded with a 4096-token context, below the declared 65536' 'the short server context is caught'
expect_out 'OLLAMA_CONTEXT_LENGTH=65536' 'and the fix is named'
ready_preset lmstudio "$LMSTUDIO_URL"
python3 "$J" set-all "$P/lmstudio.json" gemma-small >/dev/null
set_state lmstudio lmstudio
run_cm doctor
expect_out 'gemma-small [not-loaded, ctx 8192]' 'lm studio models show their state'
expect_out 'below the declared 262144 - this tier can overflow' 'a small model window is warned about'
python3 "$J" set-url "$P/lmstudio.json" http://127.0.0.1:1 >/dev/null
run_cm doctor
expect_out 'LM Studio not reachable' 'a dead server is a failure'
finish