From 4bca154cd86d3cf6add2e2834fc6503fe264c4e9 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 11 Nov 2025 16:34:53 -1000 Subject: [PATCH] Fix bin/ci-run-failed-specs to handle bare spec paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bin/ci-run-failed-specs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/ci-run-failed-specs b/bin/ci-run-failed-specs index dfe2577f96..0fd03a441f 100755 --- a/bin/ci-run-failed-specs +++ b/bin/ci-run-failed-specs @@ -105,6 +105,15 @@ else if [[ "$line" =~ rspec[[:space:]]+(\./spec/[^[:space:]]+) ]]; then spec="${BASH_REMATCH[1]}" SPECS+=("$spec") + # Also handle bare spec paths like "spec/foo.rb[1:2:3]" or "./spec/foo.rb[1:2:3]" + # Strip trailing % and whitespace + elif [[ "$line" =~ (\.?/?spec/[^[:space:]%]+) ]]; then + spec="${BASH_REMATCH[1]}" + # Normalize to ./spec/ format + if [[ ! "$spec" =~ ^\. ]]; then + spec="./$spec" + fi + SPECS+=("$spec") fi done fi @@ -153,9 +162,24 @@ echo "" # Confirm (read from /dev/tty to handle piped input) if [ -t 0 ]; then + # stdin is a TTY, read directly read -p "Run these specs now? [Y/n] " -n 1 -r REPLY else - read -p "Run these specs now? [Y/n] " -n 1 -r REPLY < /dev/tty + # 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/null + TTY_CHECK=$? + set -e # Re-enable errexit + + if [ $TTY_CHECK -eq 0 ]; then + # Successfully opened /dev/tty, use it for confirmation + 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 fi echo if [[ ! "${REPLY}" =~ ^[Yy]$ ]] && [[ ! -z "${REPLY}" ]]; then