This directory contains testing tools for the brew-change utility, supporting both local development testing and CI/CD automation.
tests/
├── README.md # This file
├── lib/
│ └── test-utils.sh # Shared test utilities and assertions
├── test-breaking-changes.sh # Breaking changes detection tests (24 tests)
└── test-brew-change-local.sh # Local testing menu (macOS/Linux) + CI mode
# Run interactive menu on your host system
./tests/test-brew-change-local.sh# Run comprehensive test suite in CI mode
./tests/test-brew-change-local.sh --ci
# Run breaking changes detection tests
./tests/test-breaking-changes.sh --ciCI mode features:
- ✅ Non-interactive: No prompts or user input required
- ✅ Structured output:
[PASS]/[FAIL]/[INFO]format - ✅ Exit codes: Returns 0 on success, non-zero on failure
- ✅ Summary report: Test statistics at the end
- ✅ CI-friendly: Perfect for GitHub Actions, GitLab CI, etc.
- ✅ Environment: Your macOS/Linux system with Homebrew tap installation
- ✅ Speed: Fast, no container overhead
- ✅ Real-world: Tests your actual tap installation
- ✅ Convenience: Immediate feedback
Features:
- 🧪 Run all functionality tests
- 📦 Test individual packages
- ⚡ Performance benchmarking
- 🌐 Network connectivity tests
- 🔍 Debug mode testing
- 📊 Configuration validation
- ✅ Help command and usage
- ✅ Invalid package handling
- ✅ Simple and verbose listing
- ✅ Single package processing
- ✅ Multiple package handling
- ✅ Breaking changes detection (24 tests)
- ⏱️ Execution timing
- 📈 System resource usage
- 💾 Memory utilization
- 🔄 Parallel processing efficiency
- 🌐 Network connectivity
- 📦 Package type detection
- 🔧 API endpoint validation
- 🏥 Environment health checks
The test-breaking-changes.sh suite provides comprehensive testing for breaking changes pattern detection:
- ✅ Pattern matching (40+ breaking change keywords)
- ✅ Case-insensitive detection
- ✅ Markdown header recognition
- ✅ False positive prevention
- ✅ Multi-line release notes
- ✅ Empty input handling
- ✅ Emoji indicator formatting
Run with: ./tests/test-breaking-changes.sh --ci
- 🔍 Detailed error reporting
- 📊 Resource monitoring
- 🛠️ Configuration validation
- 🧪 Interactive troubleshooting
# Quick function test
./tests/test-brew-change-local.sh
# Test specific package
./brew-change node
# Performance test
time ./brew-change -a# Run in CI mode (non-interactive)
./tests/test-brew-change-local.sh --ci
# Enable debug output
BREW_CHANGE_DEBUG=1 ./tests/test-brew-change-local.sh --ci
# Test breaking changes detection
./tests/test-breaking-changes.sh --ci- Results shown directly in terminal
- Debug output available with
BREW_CHANGE_DEBUG=1 - Logs printed to console
- CI mode provides structured
[PASS]/[FAIL]output
# Enable debug output
export BREW_CHANGE_DEBUG=1
# Set parallel job limit
export BREW_CHANGE_JOBS=4
# Configure retry attempts
export BREW_CHANGE_MAX_RETRIES=2The lib/test-utils.sh library provides reusable testing functions used across all test scripts.
- Command detection: Automatically finds
brew-changecommand - Assertions: Validate command success, failures, and output
- Test tracking: Count passed/failed tests automatically
- Mode awareness: Adapts output for interactive vs CI mode
- Exit codes: Proper return codes for CI integration
# Automatically find brew-change command
brew_change_cmd=$(get_brew_change_cmd)# Assert command succeeds
assert_command_success "Test name" $brew_change_cmd --help
# Assert command fails
assert_command_fails "Invalid option" $brew_change_cmd --invalid
# Assert output contains string
assert_command_output_contains "Version check" "version" $brew_change_cmd --version
# Assert output doesn't contain string
assert_command_output_not_contains "No errors" "error" $brew_change_cmdlog_info "Informational message"
log_success "Success message"
log_error "Error message"
log_warning "Warning message"# Record test results
log_test_result "Test name" "pass"
log_test_result "Another test" "fail" "Optional message"
# Print summary at end
print_test_summary
# Get appropriate exit code
get_test_exit_codeTo add new tests using the shared utilities:
test_my_feature() {
local brew_change_cmd="$1"
log_info "Testing my feature..."
# Use assertions
assert_command_success "Feature flag" $brew_change_cmd --my-feature
# Or manual testing
run_command_capture_output $brew_change_cmd --complex
if [[ $COMMAND_EXIT_CODE -eq 0 ]]; then
log_test_result "Complex test" "pass"
else
log_test_result "Complex test" "fail" "Exit: $COMMAND_EXIT_CODE"
fi
}
# Call from comprehensive_test_suite()
comprehensive_test_suite() {
# ... existing tests ...
test_my_feature "$brew_change_cmd"
}# Check permissions
chmod +x tests/test-brew-change-local.sh
# Verify brew-change installation
which brew-change
./brew-change --help
# Check dependencies
which jq curl git- Permission denied:
chmod +x tests/*.sh - brew-change not found: Ensure tap is installed via
brew tap shrwnsan/tap && brew install brew-change - Network issues: Check internet connectivity for API calls
- macOS timeout command: The
timeoutcommand is not available on macOS by default (requiresbrew install coreutils). Parallel processing tests will skip timeout protection on macOS. This is documented behavior - tests will still run, just without the timeout safeguard.
name: brew-change Tests
on: [push, pull_request]
jobs:
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install from tap
run: |
brew tap shrwnsan/tap
brew install brew-change
- name: Run test suite in CI mode
run: ./tests/test-brew-change-local.sh --ci
- name: Run breaking changes tests
run: ./tests/test-breaking-changes.sh --ciname: brew-change Tests (Linux)
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo '/home/linuxbrew/.linuxbrew/bin' >> $GITHUB_PATH
- name: Install from tap
run: brew tap shrwnsan/tap && brew install brew-change
- name: Run test suite in CI mode
run: ./tests/test-brew-change-local.sh --ci| Environment | Single Package | 13 Packages | Memory Usage |
|---|---|---|---|
| Local (macOS) | 2-4 seconds | 45-55 seconds | 15-25MB |
| Local (Linux) | 3-5 seconds | 50-60 seconds | 20-30MB |
When adding new tests:
- Update the appropriate test suite (local or breaking changes)
- Use shared utilities from
lib/test-utils.sh - Add documentation for new test scenarios
- Update this README with new coverage areas
These testing tools follow the same license as the brew-change utility.
Last Updated: 2026-01-04 Version: 1.5.3 Compatibility: macOS 10.15+, Linux with Homebrew