@@ -478,6 +478,8 @@ def initialize(binary: nil)
478478 @binary = binary || find_binary
479479 @scenarios = [ ]
480480 @profile_dir = nil
481+ @pause = false
482+ @last_dir = nil
481483 end
482484
483485 def scenario ( name , &block )
@@ -581,14 +583,16 @@ def shell
581583 puts " \e [36mrun all\e [0m Run all scenarios with live output"
582584 puts " \e [36mtest [filter]\e [0m Batch-test scenarios (captured, assertions)"
583585 puts " \e [36minspect <name>\e [0m Show scenario fixtures without running"
586+ puts " \e [36mdiff\e [0m Show git diff from last run"
584587 puts " \e [36mcd <name>\e [0m Prepare scenario and drop into its dir"
588+ puts " \e [36mpause\e [0m Toggle pause between scenarios in run-all"
585589 puts " \e [36mprofile [dir|off]\e [0m Toggle profiling (default: ./profiles)"
586590 puts " \e [36mquit\e [0m Exit"
587591 puts
588592
589593 active_ctx = nil
590594 scenario_names = @scenarios . map { |s | s . name . to_s }
591- commands = %w[ list ls run test inspect cd rerun profile quit exit q ]
595+ commands = %w[ list ls run test inspect diff cd rerun pause profile quit exit q ]
592596
593597 # Tab completion: commands first, then scenario names for run/test/inspect/cd
594598 Reline . completion_proc = proc do |input |
@@ -719,6 +723,18 @@ def shell
719723 puts "Profiling \e [32mon\e [0m → #{ @profile_dir } "
720724 end
721725
726+ when "pause"
727+ @pause = !@pause
728+ puts "Pause between scenarios: #{ @pause ? "\e [32mon\e [0m" : "\e [33moff\e [0m" } "
729+
730+ when "diff"
731+ dir = active_ctx &.dir || @last_dir
732+ if dir && Dir . exist? ( dir )
733+ show_diff ( dir )
734+ else
735+ puts "No scenario dir available. Run a scenario first."
736+ end
737+
722738 else
723739 puts "Unknown command: #{ verb } . Type \e [36mlist\e [0m for scenarios."
724740 end
@@ -733,6 +749,15 @@ def shell
733749
734750 private
735751
752+ def show_diff ( dir )
753+ return unless dir && Dir . exist? ( dir )
754+ diff = `cd #{ Shellwords . shellescape ( dir ) } && git --no-pager diff --color 2>/dev/null` . strip
755+ return if diff . empty?
756+ puts
757+ puts " \e [1m── diff ──\e [0m"
758+ diff . each_line { |l | puts " #{ l } " }
759+ end
760+
736761 def find_binary
737762 repo_bin = File . expand_path ( "../../../gh-actions-pin" , __FILE__ )
738763 return repo_bin if File . executable? ( repo_bin )
@@ -763,6 +788,7 @@ def find_scenario(name)
763788 def run_one_live ( s )
764789 puts "\e [1m── #{ s . name } ──\e [0m\n \n "
765790 ctx = s . prepare ( @binary , profile_dir : @profile_dir )
791+ keep = ENV [ "KEEP_FIXTURES" ]
766792 begin
767793 result = ctx . run_pty
768794 puts
@@ -775,14 +801,23 @@ def run_one_live(s)
775801 pdir = File . join ( @profile_dir , s . name . to_s )
776802 puts " \e [2mprofile: #{ pdir } \e [0m"
777803 end
804+ show_diff ( ctx . dir )
805+ @last_dir = ctx . dir
778806 puts
779807 ensure
780- ctx . teardown unless ENV [ "KEEP_FIXTURES" ]
808+ ctx . teardown unless keep
781809 end
782810 end
783811
784812 def run_all_live
785- @scenarios . each { |s | run_one_live ( s ) }
813+ @scenarios . each_with_index do |s , i |
814+ run_one_live ( s )
815+ if @pause && i < @scenarios . size - 1
816+ print "\e [2m press Enter to continue (q to stop)…\e [0m "
817+ input = $stdin. gets &.strip
818+ break if input &.start_with? ( "q" )
819+ end
820+ end
786821 rescue Interrupt
787822 puts "\n \e [33m⊘ interrupted\e [0m"
788823 end
0 commit comments