-
-
Notifications
You must be signed in to change notification settings - Fork 638
Fix bin/ci-run-failed-specs to handle bare spec paths #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The script previously only parsed spec paths in the format "rspec ./spec/..." but failed on bare formats like "spec/system/integration_spec.rb[1:1:6:1:2]%" which is what users might copy from shell output. Changes: - Add regex pattern to match bare spec paths (with or without ./ prefix) - Strip trailing % characters from spec paths - Normalize all paths to ./spec/ format for consistency - Improve TTY detection to avoid spurious error messages - Auto-confirm when TTY is unavailable instead of failing Now supports all these input formats: - spec/foo.rb[1:2:3]% - ./spec/foo.rb[1:2:3] - rspec ./spec/foo.rb[1:2:3] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: Fix bin/ci-run-failed-specs to handle bare spec pathsSummaryThis PR improves the bin/ci-run-failed-specs script to handle bare spec paths that users might copy directly from their terminal. Overall, the changes are well-implemented and solve a real usability issue. Strengths
Potential Issues1. Over-Broad Regex Pattern (Medium Priority)Issue: The regex (.?/?spec/[^[:space:]%]+) might match unintended lines like comments or directory listings. Suggestion: Consider making it more specific by requiring .rb extension or brackets. 2. Silent Auto-Confirmation (Low Priority)Issue: Line 180 auto-confirms when TTY is unavailable, which could surprise users. Suggestion: Document this behavior in the help text under Features section. 3. Edge Case: Paths Without Extensions (Low Priority)The regex doesn't require .rb extension. Impact is minimal since RSpec will fail gracefully on invalid paths. Testing RecommendationsConsider testing these additional cases:
Best Practices Check
Security Considerations
RecommendationAPPROVE with minor suggestions The changes are solid and solve a real usability problem. The regex pattern could be more specific to avoid false positives, but even as-is, it's unlikely to cause issues in practice since RSpec will gracefully handle invalid paths. The enhanced TTY handling is well-implemented and makes the script more robust in different execution environments. Overall Assessment: Ready to merge after considering the regex specificity suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
bin/ci-run-failed-specs (2)
108-116: Consider tightening the regex pattern to avoid edge cases.The pattern
\.?/?matches dot and slash independently, which could incorrectly match.spec/(missing slash) or/spec/(missing dot prefix). While these cases are unlikely in practice, the regex could be more precise.Consider this refactor:
- elif [[ "$line" =~ (\.?/?spec/[^[:space:]%]+) ]]; then - spec="${BASH_REMATCH[1]}" - # Normalize to ./spec/ format - if [[ ! "$spec" =~ ^\. ]]; then - spec="./$spec" - fi - SPECS+=("$spec") + elif [[ "$line" =~ (\./)?spec/[^[:space:]%]+ ]]; then + # Always normalize to ./spec/ format + spec="./${BASH_REMATCH[0]#./}" + SPECS+=("$spec")This explicitly matches the optional
./prefix and unconditionally normalizes all paths.
169-183: Consider simplifying the TTY check using anifconditional.The
set +e/set -epattern works correctly but can be simplified. Commands inifconditionals are allowed to fail without triggeringset -eexit, making the toggle unnecessary.Apply this diff to simplify:
- # stdin is not a TTY (piped input), try /dev/tty - # Check if we can actually open /dev/tty by attempting to use it in a subshell - set +e # Temporarily disable errexit for the check - (exec 0</dev/tty) 2>/dev/null - TTY_CHECK=$? - set -e # Re-enable errexit - - if [ $TTY_CHECK -eq 0 ]; then - # Successfully opened /dev/tty, use it for confirmation + # stdin is not a TTY (piped input), try /dev/tty + if (exec 0</dev/tty) 2>/dev/null; then read -p "Run these specs now? [Y/n] " -n 1 -r REPLY < /dev/tty else - # Cannot open /dev/tty, auto-confirm echo "Run these specs now? [Y/n] Y (auto-confirmed, TTY unavailable)" REPLY="Y" fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bin/ci-run-failed-specs(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
Code Review - PR #1989OverviewThis PR enhances the ✅ Strengths
💡 Code Quality ObservationsGood practices:
🔍 Potential Considerations
🧪 Testing ConsiderationsThe PR description mentions testing with: echo "spec/system/integration_spec.rb[1:1:6:1:2]%" | bin/ci-run-failed-specsAdditional test scenarios to consider (though not blocking):
🔒 SecurityNo security concerns. The script:
📝 DocumentationThe help text and comments adequately explain the new functionality. The commit message and PR description are thorough and well-written. 🎯 VerdictThis is a high-quality enhancement that meaningfully improves developer experience. The code is clean, safe, and well-thought-out. The TTY detection improvement alone is valuable for automated environments. No blocking issues identified. The implementation follows repository conventions (as per CLAUDE.md) and enhances an existing utility script without introducing risk. Minor Suggestions (Optional)
Great work on this improvement! 🚀 |
Summary
Fixes the
bin/ci-run-failed-specsscript to handle bare spec paths that users might copy directly from their terminal, likespec/system/integration_spec.rb[1:1:6:1:2]%.Previously, the script only recognized the format
rspec ./spec/...and would fail with "No specs found!" when given bare spec paths.Changes
./prefix)%characters from spec paths (common in shell output)./spec/format for consistencyTest Plan
The script now correctly handles all these input formats:
spec/foo.rb[1:2:3]%(bare with trailing %)./spec/foo.rb[1:2:3](with ./ prefix)rspec ./spec/foo.rb[1:2:3](full rspec command format)Tested with:
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit