Class: Ace::TestRunner::CLI::Commands::Test

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/test_runner/cli/commands/test.rb

Overview

ace-support-cli Command class for the test command

This command runs tests with flexible package, target, and file selection. All business logic is inline in this single command class.

Instance Method Summary collapse

Instance Method Details

#call(args: [], **options) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ace/test_runner/cli/commands/test.rb', line 114

def call(args: [], **options)
  if options[:version]
    puts "ace-test #{Ace::TestRunner::VERSION}"
    return 0
  end

  # Type-convert numeric options (ace-support-cli returns strings, Thor converted to integers)
  # This maintains parity with the Thor implementation
  numeric_options = %i[timeout max_display profile cleanup_keep cleanup_age]
  numeric_options.each do |key|
    options[key] = options[key].to_i if options[key]
  end

  if options[:target] && args.none? { |arg| !arg.start_with?("-") && !File.exist?(arg) }
    args = [options[:target]] + args
  end

  # Build test options with defaults
  test_options = build_test_options(options)

  # Display config summary
  display_config_summary(test_options)

  # Handle special modes first
  result = handle_special_modes(args, test_options)
  return result if result

  # Parse CLI arguments using CliArgumentParser
  begin
    arg_parser = Molecules::CliArgumentParser.new(args)
    parsed_args = arg_parser.parse
    test_options.merge!(parsed_args)
  rescue ArgumentError => e
    raise Ace::Support::Cli::Error.new(e.message)
  end

  # Run tests with special exit! handling for Minitest compatibility
  run_tests_with_exit_handling(test_options)
rescue Ace::TestRunner::Error => e
  raise Ace::Support::Cli::Error.new(e.message)
rescue Interrupt
  raise Ace::Support::Cli::Error.new("Test execution interrupted", exit_code: 130)
rescue => e
  raise Ace::Support::Cli::Error.new("Unexpected error: #{e.message}")
end