| Crates.io | cli-testing-specialist |
| lib.rs | cli-testing-specialist |
| version | 1.0.10 |
| created_at | 2025-11-12 06:20:21.825333+00 |
| updated_at | 2025-11-16 03:59:17.843286+00 |
| description | Comprehensive testing framework for CLI tools - automated analysis, test generation, and security validation |
| homepage | |
| repository | https://github.com/sanae-abe/cli-testing-specialist |
| max_upload_size | |
| id | 1928865 |
| size | 1,239,671 |
Version: 1.0.10 Last Updated: 2025-11-16 Status: Production Ready License: MIT
A comprehensive testing framework that automatically validates the quality and security of CLI tools. Built with Rust for maximum performance and reliability.
CLI Testing Specialist is a production-ready testing framework that automatically generates and executes comprehensive test suites for CLI tools.
# 1. Install cli-testing-specialist
cargo install --git https://github.com/sanae-abe/cli-testing-specialist
# 2. Analyze CLI tool
cli-testing-specialist analyze /usr/bin/curl -o curl-analysis.json
# 3. Generate tests (all categories)
cli-testing-specialist generate curl-analysis.json -o curl-tests -c all
# 4. Run tests and generate reports
cli-testing-specialist run curl-tests -f all -o curl-reports
# 5. View HTML report
open curl-reports/curl-tests-report.html # macOS
# xdg-open curl-reports/curl-tests-report.html # Linux
# Install from crates.io
cargo install cli-testing-specialist
# Verify installation
cli-testing-specialist --version
# Install from GitHub
cargo install --git https://github.com/sanae-abe/cli-testing-specialist
# Verify installation
cli-testing-specialist --version
# Clone repository
git clone https://github.com/sanae-abe/cli-testing-specialist
cd cli-testing-specialist
# Install Git hooks (auto-format on commit)
./scripts/install-hooks.sh
# Build and test
cargo build
cargo test
# macOS
brew install bats-core
# Ubuntu/Debian
sudo apt-get install bats
# Manual installation
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
cli-testing-specialist is optimized for standard CLI tools. See docs/TARGET-TOOLS.md for detailed guidance.
✅ Tested & Supported:
⚠️ Untested (Estimated 70-80% compatible):
📋 Planned Testing: v1.1.0+
See docs/TARGET-TOOLS.md for complete guidelines, language-specific details, and best practices.
Real-world CLI tools tested with 100% success rate:
| Tool | Language | Framework | Tests | Success Rate | Notes |
|---|---|---|---|---|---|
| package-publisher | Node.js | commander.js | 17/17 | 100% | NPM package publisher with multi-command support |
| backup-suite | Rust | clap | 15/15 | 100% | Backup automation tool with encryption |
| cmdrun | Rust | clap | 14/14 | 100% | Command runner with TOML configuration |
| cldev | Rust | clap | 15/15 | 100% | Interactive development CLI with i18n |
Framework Compatibility Verified:
| Category | Description | Default |
|---|---|---|
| Basic Validation | Help, version, exit codes | ✅ Enabled |
| Help | Comprehensive subcommand help validation | ✅ Enabled |
| Security | Command injection, null bytes, path traversal | ✅ Enabled |
| Path Handling | Special characters, deep hierarchies, Unicode | ✅ Enabled |
| Multi-Shell | bash/zsh compatibility | ✅ Enabled |
| Input Validation | Numeric/path/enum option validation | ✅ Enabled |
| Destructive Operations | Confirmation prompts, --yes/--force flags | ✅ Enabled |
| Performance | Startup time, memory usage | ✅ Enabled |
| Directory Traversal | Large file count, deep nesting, symlink loops | ⚠️ Opt-in* |
* Directory Traversal tests are opt-in via --include-intensive flag to prevent CI environment issues (disk space, resource limits).
# Default: All categories except Directory Traversal
cli-testing-specialist generate analysis.json -c all
# Include resource-intensive tests
cli-testing-specialist generate analysis.json -c all --include-intensive
# Specific categories only
cli-testing-specialist generate analysis.json -c basic,security,path
Built with Rust for maximum performance - 10x+ faster than shell-based alternatives.
Measured with Criterion.rs on production hardware:
| CLI Tool | Complexity | Analysis Time | vs Bash Prototype |
|---|---|---|---|
| curl | Small (~50-100 options) | 109 ms | 11x faster |
| docker | Medium (~100+ options) | 224 ms | 11x faster |
| kubectl | Large (100+ subcommands) | 230 ms | 17x faster |
| npm | Medium (many subcommands) | 329 ms | 7x faster |
lto = "thin")See docs/PERFORMANCE.md for detailed benchmarks and methodology.
.md)Human-readable format for GitHub/GitLab display
cli-testing-specialist run ./tests -f markdown -o ./reports
.json)Optimal for CI/CD integration and programmatic processing
cli-testing-specialist run ./tests -f json -o ./reports
# Parse with jq
jq '[.suites[].tests[] | select(.status == "passed")] | length' reports/tests-report.json
.html)Interactive browser display with search and filtering
cli-testing-specialist run ./tests -f html -o ./reports
open reports/tests-report.html
HTML Features:
.xml)CI/CD integration (GitHub Actions, GitLab CI, Jenkins)
cli-testing-specialist run ./tests -f junit -o ./reports
cli-testing-specialist run ./tests -f all -o ./reports
For details, see docs/REPORT-FORMATS.md.
New in v1.1.0: Use the official GitHub Action for the easiest integration:
name: CLI Testing
on: [push, pull_request]
jobs:
cli-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build your CLI
run: cargo build --release
- name: Test CLI
uses: ./.github/actions/cli-testing-specialist
with:
binary: ./target/release/your-cli
categories: all
format: all
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cli-test-reports
path: cli-test-reports/
Advanced Configuration:
- name: Test CLI with custom settings
uses: ./.github/actions/cli-testing-specialist
with:
binary: ./target/release/your-cli
categories: 'basic,security,path' # Specific categories
format: 'junit' # CI-friendly format
output: 'test-results' # Custom output directory
include-intensive: 'false' # Skip resource-intensive tests
version: '1.1.0' # Specific version
If you prefer manual setup:
name: CLI Testing
on: [push, pull_request]
jobs:
cli-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cli-testing-specialist
run: |
cargo install --git https://github.com/sanae-abe/cli-testing-specialist
- name: Build your CLI
run: cargo build --release
- name: Analyze CLI
run: |
cli-testing-specialist analyze \
./target/release/your-cli \
-o analysis.json
- name: Generate tests
run: |
cli-testing-specialist generate \
analysis.json \
-o tests \
-c all
- name: Install BATS
run: sudo apt-get install -y bats
- name: Run tests
run: |
cli-testing-specialist run \
tests \
-f all \
-o reports
- name: Upload reports
uses: actions/upload-artifact@v4
with:
name: test-reports
path: reports/
cli-test:
image: rust:latest
script:
- cargo install --git https://github.com/sanae-abe/cli-testing-specialist
- cargo build --release
- cli-testing-specialist analyze ./target/release/your-cli -o analysis.json
- cli-testing-specialist generate analysis.json -o tests -c all
- apt-get update && apt-get install -y bats
- cli-testing-specialist run tests -f all -o reports
artifacts:
paths:
- reports/
IMPORTANT: Security tests expect tools to reject malicious inputs with non-zero exit codes.
// Command injection test
cli-test --name 'test; rm -rf /'
// Expected: exit code 1 (rejection) ✅
// NOT exit code 0 (success) ❌
Injection Attacks: Command injection, null byte injection
injection, criticalPath Traversal: Directory traversal attempts
path-traversal, criticalBuffer Overflow: Extremely long inputs
buffer-overflow, informational# Analyze with custom output
cli-testing-specialist analyze /usr/bin/curl -o custom-analysis.json
# Generate specific categories
cli-testing-specialist generate analysis.json -c basic,security,path
# Include intensive tests
cli-testing-specialist generate analysis.json -c all --include-intensive
# Run with timeout
cli-testing-specialist run tests --timeout 120 -f all -o reports
# Skip specific categories
cli-testing-specialist run tests --skip destructive-ops,directory-traversal
# Skip directory traversal tests
export SKIP_DIRECTORY_TRAVERSAL_TESTS=1
cli-testing-specialist run tests -f all -o reports
Create a .cli-test-config.yml file in your project root to customize test generation for your CLI tool.
Auto-Detection: The tool automatically looks for .cli-test-config.yml in the current directory.
Basic Example:
version: "1.0"
tool_name: "backup-suite"
tool_version: "1.0.0"
test_adjustments:
security:
skip_options:
- name: "lang"
reason: "Language selection is an enum, not a security risk"
custom_tests:
- name: "custom-security-test"
command: "backup-suite --config /etc/passwd"
expected_exit_code: 1
description: "Reject system config file access"
directory_traversal:
test_directories:
- path: "/tmp/test-100-files"
file_count: 100
create: true
cleanup: true
- path: "/tmp/test-deep-5"
depth: 5
create: true
cleanup: true
destructive_ops:
env_vars:
BACKUP_SUITE_YES: "true"
CI: "true"
cancel_exit_code: 2
global:
timeout: 60
Configuration Reference:
Security Considerations (4-Layer Defense):
.cli-test-config.yml creationtest_directories over setup_commands)Examples:
examples/backup-suite.cli-test-config.ymlexamples/backup-suite-implementation.mdSee docs/TOOL_SPECIFIC_CONFIG.md for complete documentation.
cli-testing-specialist/
├── Cargo.toml # Rust project configuration
├── Cargo.lock
├── README.md # This file
├── LICENSE # MIT License
├── src/
│ ├── main.rs # Entry point
│ ├── lib.rs # Library exports
│ ├── cli/ # CLI interface (clap)
│ ├── analyzer/ # CLI analysis engine
│ ├── generator/ # Test case generation
│ ├── runner/ # BATS test execution
│ ├── reporter/ # Report generation (MD/JSON/HTML/JUnit)
│ ├── types/ # Type definitions
│ ├── error.rs # Error types
│ └── utils/ # Utilities
├── tests/ # Integration tests
├── benches/ # Performance benchmarks
└── docs/
├── RUST_V1_DESIGN.md # Design document
├── TARGET-TOOLS.md # Target tool guidelines
└── REPORT-FORMATS.md # Report format guide
MIT License - see LICENSE file for details.
Contributions are welcome! Please:
For major changes, please open an issue first to discuss the proposed changes.
docs/ directory
CI/CD Improvements:
Windows Platform:
Win32_System_Threading feature for Job Object supportDocumentation:
All CI/CD pipelines now passing successfully ✅
Revolutionary No-Args Behavior Detection:
[OPTIONS] <COMMAND>), different behaviorsHTML Report Improvements:
Technical:
BehaviorInferrer::execute_and_measure()wait-timeout = "0.2" for process timeout handlingNo-Args Test Assertion Relaxation:
Clippy Warning Fix:
TestCategory::default() to standard_categories().claude/CLAUDE.mdRequired Arguments Detection:
<ID>, <FILE>)Dependency Updates:
cargo auditDocumentation Improvements 📚:
docs/TARGET-TOOLS.md guide for tool compatibility assessmentCritical Security Test Fix 🔒:
Security Fix 🔒:
--include-intensive flagBuilt with ❤️ using Rust