Class: Ace::Test::EndToEndRunner::Molecules::ProgressDisplayManager
- Inherits:
-
Object
- Object
- Ace::Test::EndToEndRunner::Molecules::ProgressDisplayManager
- Defined in:
- lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb
Overview
Animated ANSI table display manager for E2E test output (–progress mode). Updates test rows in place using cursor movement escape codes. Modeled on ace-test-runner’s DisplayManager for visual consistency.
Instance Method Summary collapse
-
#initialize(scenarios, output:, parallel:) ⇒ ProgressDisplayManager
constructor
A new instance of ProgressDisplayManager.
-
#initialize_display ⇒ Object
Print header and initial table with all tests in waiting state.
-
#refresh ⇒ Object
Refresh running test rows to update elapsed timers Throttled to ~4Hz — redraws are expensive with ANSI cursor movement.
-
#show_single_result(result) ⇒ Object
Print a single-test result line (for run-single-test mode).
-
#show_summary(results, report_path) ⇒ Object
Print structured summary block.
-
#test_completed(scenario, result, completed, total) ⇒ Object
Update row when a test completes.
-
#test_started(scenario) ⇒ Object
Update row when a test begins.
Constructor Details
#initialize(scenarios, output:, parallel:) ⇒ ProgressDisplayManager
Returns a new instance of ProgressDisplayManager.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 14 def initialize(scenarios, output:, parallel:) @scenarios = scenarios @output = output @parallel = parallel @use_color = output.respond_to?(:tty?) && output.tty? @start_time = Time.now @last_refresh = Time.at(0) @lines = {} # scenario.test_id => line number @states = {} # scenario.test_id => :waiting | :running | :completed @results = {} # scenario.test_id => Models::TestResult @started_at = {} # scenario.test_id => Time @title_width = calculate_title_width end |
Instance Method Details
#initialize_display ⇒ Object
Print header and initial table with all tests in waiting state
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 29 def initialize_display h = Atoms::DisplayHelpers package = @scenarios.first&.package || "unknown" # Clear screen (preserves scrollback) @output.print "\033[H\033[J" @output.puts h.separator @output.puts " E2E Tests: #{package} (#{@scenarios.size} tests)" @output.puts h.separator @output.puts @scenarios.each_with_index do |scenario, index| line = index + 5 # account for header lines @lines[scenario.test_id] = line @states[scenario.test_id] = :waiting print_row(scenario) end @output.puts @output.puts @footer_line = @lines.values.max + 3 end |
#refresh ⇒ Object
Refresh running test rows to update elapsed timers Throttled to ~4Hz — redraws are expensive with ANSI cursor movement
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 77 def refresh now = Time.now return if now - @last_refresh < REFRESH_INTERVAL @last_refresh = now @states.each do |test_id, state| next unless state == :running scenario = @scenarios.find { |s| s.test_id == test_id } print_row(scenario) if scenario end end |
#show_single_result(result) ⇒ Object
Print a single-test result line (for run-single-test mode)
94 95 96 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 94 def show_single_result(result) @output.puts Atoms::DisplayHelpers.format_single_result(result, use_color: @use_color) end |
#show_summary(results, report_path) ⇒ Object
Print structured summary block
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 101 def show_summary(results, report_path) # Move cursor past the display area move_to_line(@footer_line + 1) @output.puts lines = Atoms::DisplayHelpers.format_summary_lines( results, Time.now - @start_time, report_path, use_color: @use_color ) lines.each { |line| @output.puts line } end |
#test_completed(scenario, result, completed, total) ⇒ Object
Update row when a test completes
68 69 70 71 72 73 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 68 def test_completed(scenario, result, completed, total) @states[scenario.test_id] = :completed @results[scenario.test_id] = result print_row(scenario) end |
#test_started(scenario) ⇒ Object
Update row when a test begins
56 57 58 59 60 61 |
# File 'lib/ace/test/end_to_end_runner/molecules/progress_display_manager.rb', line 56 def test_started(scenario) @states[scenario.test_id] = :running @started_at[scenario.test_id] = Time.now print_row(scenario) end |