Skip to content

Commit b659390

Browse files
justin808claude
andauthored
Fix bin/ci-run-failed-specs to handle bare spec paths (#1989)
## Summary Fixes the `bin/ci-run-failed-specs` script to handle bare spec paths that users might copy directly from their terminal, like `spec/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 - Added regex pattern to match bare spec paths (with or without `./` prefix) - Strip trailing `%` characters from spec paths (common in shell output) - Normalize all paths to `./spec/` format for consistency - Improved TTY detection to avoid spurious error messages when piping input - Auto-confirm when TTY is unavailable instead of failing ## Test 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: ```bash echo "spec/system/integration_spec.rb[1:1:6:1:2]%" | bin/ci-run-failed-specs ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1989) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced CI test runner to better handle test file path formats * Improved user confirmation prompts for automated CI environments <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8a977b3 commit b659390

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

bin/ci-run-failed-specs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ else
105105
if [[ "$line" =~ rspec[[:space:]]+(\./spec/[^[:space:]]+) ]]; then
106106
spec="${BASH_REMATCH[1]}"
107107
SPECS+=("$spec")
108+
# Also handle bare spec paths like "spec/foo.rb[1:2:3]" or "./spec/foo.rb[1:2:3]"
109+
# Strip trailing % and whitespace
110+
elif [[ "$line" =~ (\.?/?spec/[^[:space:]%]+) ]]; then
111+
spec="${BASH_REMATCH[1]}"
112+
# Normalize to ./spec/ format
113+
if [[ ! "$spec" =~ ^\. ]]; then
114+
spec="./$spec"
115+
fi
116+
SPECS+=("$spec")
108117
fi
109118
done
110119
fi
@@ -153,9 +162,24 @@ echo ""
153162

154163
# Confirm (read from /dev/tty to handle piped input)
155164
if [ -t 0 ]; then
165+
# stdin is a TTY, read directly
156166
read -p "Run these specs now? [Y/n] " -n 1 -r REPLY
157167
else
158-
read -p "Run these specs now? [Y/n] " -n 1 -r REPLY < /dev/tty
168+
# stdin is not a TTY (piped input), try /dev/tty
169+
# Check if we can actually open /dev/tty by attempting to use it in a subshell
170+
set +e # Temporarily disable errexit for the check
171+
(exec 0</dev/tty) 2>/dev/null
172+
TTY_CHECK=$?
173+
set -e # Re-enable errexit
174+
175+
if [ $TTY_CHECK -eq 0 ]; then
176+
# Successfully opened /dev/tty, use it for confirmation
177+
read -p "Run these specs now? [Y/n] " -n 1 -r REPLY < /dev/tty
178+
else
179+
# Cannot open /dev/tty, auto-confirm
180+
echo "Run these specs now? [Y/n] Y (auto-confirmed, TTY unavailable)"
181+
REPLY="Y"
182+
fi
159183
fi
160184
echo
161185
if [[ ! "${REPLY}" =~ ^[Yy]$ ]] && [[ ! -z "${REPLY}" ]]; then

0 commit comments

Comments
 (0)