Skip to content

test: add pytest test suite and CI workflow#14

Closed
joshbouncesecurity wants to merge 13 commits intoknostic:masterfrom
joshbouncesecurity:add-test-suite
Closed

test: add pytest test suite and CI workflow#14
joshbouncesecurity wants to merge 13 commits intoknostic:masterfrom
joshbouncesecurity:add-test-suite

Conversation

@joshbouncesecurity
Copy link

Closes #13

Summary

  • Adds a pytest test suite covering parsers, token tracking, language detection, and Go CLI integration
  • Adds a GitHub Actions CI workflow that runs tests on Linux, macOS, and Windows

Tests (60 total)

Test file Tests Coverage
test_token_tracker.py 8 Pricing, cumulative tracking, reset, summaries
test_parser_adapter.py 11 Language detection (Python/JS/mixed), venv/node_modules exclusion
test_python_parser.py 19 All 4 parser phases: scanner, extractor, call graph, unit generator
test_js_parser.py 10 JS scanner, TypeScript analyzer, unit generator, full pipeline
test_go_cli.py 12 Version, help, parse commands, API key handling

CI workflow

Two jobs, each running on ubuntu/macos/windows (6 total):

  • python-tests: pytest suite for parsers and token tracker
  • go-tests: go vet + go build + Go CLI integration tests

Triggers on push to master and on pull requests.

Known xfails on Windows

  • ts-morph backslash path resolution in TypeScript analyzer
  • Unicode checkmarks in JS test_pipeline.py on cp1252 encoding

These are pre-existing issues, not introduced by this PR.

Test plan

  • All 60 tests pass on Linux, macOS, and Windows (verified via CI)
  • No changes to existing source code — tests only

Do not delete the source branch until both the fork PR and upstream PR have been merged. The upstream PR depends on the branch existing in the fork.

🤖 Generated with Claude Code

joshbouncesecurity and others added 7 commits March 18, 2026 16:33
Tests cover:
- TokenTracker: pricing, cumulative tracking, reset, summaries
- Parser adapter: language detection (Python/JS/mixed), venv/node_modules exclusion
- Python parser phases: scanner, function extractor, call graph builder, unit generator
- JS parser: scanner, TypeScript analyzer, unit generator, full pipeline
- Go CLI wrapper: version, help, parse commands, API key handling

Includes sample fixtures for Python and JavaScript repos.

Known xfails on Windows:
- ts-morph backslash path resolution in TypeScript analyzer
- Unicode checkmarks in JS test_pipeline.py on cp1252 encoding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three jobs:
- python-tests: pytest suite (parsers + token tracker) on all 3 OSes
- go-build: go vet + go build on all 3 OSes
- go-cli-integration: Go CLI integration tests (depends on go-build)

Runs on push to master and on pull requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Will revert to master-only before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove needs dependency so go-cli-integration runs in parallel
- Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 to suppress deprecation warnings
- Add cache-dependency-path for Go module cache
- Revert trigger to master-only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- checkout@v4 → v5, setup-node@v4 → v5 (both support Node.js 24)
- node-version 20 → 22
- Remove FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env var

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Avoids duplicate checkout/setup. Also re-add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24
since setup-python@v5 and setup-go@v5 don't have Node.js 24 releases yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@joshbouncesecurity joshbouncesecurity changed the title Add pytest test suite and CI workflow test: add pytest test suite and CI workflow Mar 18, 2026
joshbouncesecurity and others added 6 commits March 19, 2026 09:48
* Add pytest test suite for parsers and core utilities

Tests cover:
- TokenTracker: pricing, cumulative tracking, reset, summaries
- Parser adapter: language detection (Python/JS/mixed), venv/node_modules exclusion
- Python parser phases: scanner, function extractor, call graph builder, unit generator
- JS parser: scanner, TypeScript analyzer, unit generator, full pipeline
- Go CLI wrapper: version, help, parse commands, API key handling

Includes sample fixtures for Python and JavaScript repos.

Known xfails on Windows:
- ts-morph backslash path resolution in TypeScript analyzer
- Unicode checkmarks in JS test_pipeline.py on cp1252 encoding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add CI workflow to run tests on Linux, macOS, and Windows

Three jobs:
- python-tests: pytest suite (parsers + token tracker) on all 3 OSes
- go-build: go vet + go build on all 3 OSes
- go-cli-integration: Go CLI integration tests (depends on go-build)

Runs on push to master and on pull requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: temporarily trigger on add-test-suite branch for testing

Will revert to master-only before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: fix warnings and run all jobs in parallel

- Remove needs dependency so go-cli-integration runs in parallel
- Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 to suppress deprecation warnings
- Add cache-dependency-path for Go module cache
- Revert trigger to master-only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: use latest action versions instead of Node.js 24 env workaround

- checkout@v4 → v5, setup-node@v4 → v5 (both support Node.js 24)
- node-version 20 → 22
- Remove FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env var

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: merge go-build and go-cli-integration into single job

Avoids duplicate checkout/setup. Also re-add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24
since setup-python@v5 and setup-go@v5 don't have Node.js 24 releases yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: remove temporary branch trigger

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: support local Claude Code session for LLM calls

Add OPENANT_LOCAL_CLAUDE mode that calls the claude CLI in print mode
instead of the Anthropic API directly. Uses the local Claude Code
session's authentication, so no API key is needed.

Changes:
- Add utilities/local_claude.py with LocalClaudeClient, a drop-in
  replacement for anthropic.Anthropic() that routes through `claude -p`
- Add create_anthropic_client() factory that returns the right client
  based on OPENANT_LOCAL_CLAUDE env var
- Update all direct anthropic.Anthropic() callsites to use the factory
  (agentic_enhancer, finding_verifier, application_context, report
  generators)
- Skip API key requirement in Go CLI when OPENANT_LOCAL_CLAUDE=true
- Add LOCAL_CLAUDE.md with setup and usage instructions
- Token usage and cost tracking works in both modes (CLI JSON output
  includes usage data)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove LOCAL_CLAUDE.md from tracking

Keep as local-only documentation, not part of the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use platform-aware binary name (openant.exe on Windows, openant elsewhere)
- Split CI build step per OS to produce correct binary name
- Add verification step to catch missing binary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-existing issue: test_pipeline.py uses Unicode checkmarks that crash
on Windows cp1252 encoding. Will be fixed in a separate PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep our fixes: platform-aware binary name, Unicode skip, CI improvements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@joshbouncesecurity
Copy link
Author

Closing — branch had unrelated commits mixed in. Reopening as a clean PR.

@joshbouncesecurity joshbouncesecurity deleted the add-test-suite branch March 19, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add automated test suite and CI workflow

1 participant