Skip to content

Commit 4bca154

Browse files
justin808claude
andcommitted
Fix bin/ci-run-failed-specs to handle bare spec paths
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]>
1 parent 8a977b3 commit 4bca154

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)