Class: Ace::Test::EndToEndRunner::Molecules::ProgressDisplayManager

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(scenarios, output:, parallel:) ⇒ ProgressDisplayManager

Returns a new instance of ProgressDisplayManager.

Parameters:

  • scenarios (Array<Models::TestScenario>)

    tests to run

  • output (IO)

    output stream

  • parallel (Integer)

    parallelism level



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_displayObject

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
  update_footer
end

#refreshObject

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
  update_footer
end

#show_single_result(result) ⇒ Object

Print a single-test result line (for run-single-test mode)

Parameters:



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

Parameters:



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

Parameters:



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)
  update_footer
end

#test_started(scenario) ⇒ Object

Update row when a test begins

Parameters:



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)
  update_footer
end