Add CLI test coverage (0% → 72.83%)
The Resyntax CLI had no test coverage for argument parsing or file refactoring functionality.
Changes
-
Added 21 test cases in
cli.rktcovering:- Argument parsing for
analyzeandfixcommands (all flags and options) - End-to-end refactoring with temporary files
- Output format validation (plain text, JSON, commit messages)
- Argument parsing for
-
Test design:
- Self-contained with temporary directories (no repository pollution)
- Validates both option parsing and actual behavior
- Robust assertions on file modifications, not just output text
-
Bug fix: Corrected typo in help text ("anaylze" → "analyze")
Coverage gaps (intentional)
Uncovered lines are rarely-used options (--package, --local-git-repository, --refactoring-suite, --refactoring-rule) that would require non-trivial test infrastructure.
(test-case "resyntax-fix-run: respects --max-fixes limit"
(define test-file (make-test-racket-file test-dir "test.rkt"
"#lang racket/base\n\n(or 1 (or 2 3))\n(and 4 (and 5 6))\n"))
(call-with-args resyntax-fix-run
(list "--file" (path->string test-file) "--max-fixes" "1"))
;; Verify exactly one of two issues was fixed
(define fixed-content (file->string test-file))
(check-true (xor (string-contains? fixed-content "(or 1 2 3)")
(string-contains? fixed-content "(and 4 5 6)"))))
Original prompt
This section details on the original issue you should resolve
<issue_title>Resyntax CLI has poor test coverage</issue_title> <issue_description>A few tests that check that it parses arguments correctly and refactors some temp files would go a long way.</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes jackfirth/resyntax#724
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.