Class: Testprune::CLI
- Inherits:
-
Object
- Object
- Testprune::CLI
- Defined in:
- lib/testprune/cli.rb
Overview
Command-line front end. Three real commands:
run boots the target suite under coverage instrumentation -> run.json
report analyzes run.json and prints grouped candidates (read-only)
apply prompts for approval, then writes a removal patch (never edits in place)
Constant Summary collapse
- NOISY_PATTERNS =
%w[selenium request piper integration].freeze
- BANNER =
<<~TXT testprune — audit a Ruby test suite for redundant coverage Usage: testprune scan [options] [-- <test command>] testprune report [options] testprune apply [options] testprune prune [options] [-- <test command>] Commands: scan Run the target suite instrumented; capture per-test coverage + timing report Analyze captured data and print removal candidates (read-only) apply Review candidates, ask for approval, emit a git-applyable patch prune Run scan + apply in one step (the full workflow) Options: -s, --source PATH Source dir to analyze (repeatable; default: app, lib) -o, --output DIR Output dir for captured data (default: .testprune) --baseline FRAC Treat units run by >= FRAC of tests as shared-setup noise and subtract them (0..1; default 0.5; 0 to disable) --json Emit machine-readable JSON (report only) -h, --help Show this help -v, --version Show version TXT
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.start(argv) ⇒ Object
39 40 41 |
# File 'lib/testprune/cli.rb', line 39 def self.start(argv) new.run(argv) end |
Instance Method Details
#run(argv) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/testprune/cli.rb', line 43 def run(argv) argv = argv.dup command = argv.shift case command when 'scan' then cmd_scan(argv) when 'report' then cmd_report(argv) when 'apply' then cmd_apply(argv) when 'prune' then cmd_prune(argv) when '-v', '--version' then puts(Testprune::VERSION) when nil, '-h', '--help' then puts(BANNER) else warn("testprune: unknown command #{command.inspect}\n\n#{BANNER}") return 1 end 0 rescue Testprune::Error => e warn("testprune: #{e.}") 1 end |