Class: Ace::Test::EndToEndRunner::CLI::Commands::RunSuite

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

Overview

CLI command for running E2E test suite across all packages

Discovers all E2E tests in the monorepo and executes them with optional parallel execution and affected package filtering.

Instance Method Summary collapse

Instance Method Details

#call(packages: nil, **options) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
# File 'lib/ace/test/end_to_end_runner/cli/commands/run_suite.rb', line 76

def call(packages: nil, **options)
  options = coerce_types(options, parallel: :integer, timeout: :integer)

  parallel = options[:parallel]
  affected = !!options[:affected]
  only_failures = !!options[:only_failures]
  prune_artifacts = !!options[:prune_artifacts]
  tags = parse_csv_list(options[:tags])
  exclude_tags = parse_csv_list(options[:exclude_tags])
  if only_failures && prune_artifacts
    raise Ace::Support::Cli::Error.new(
      "--prune-artifacts cannot be used with --only-failures"
    )
  end
  retry_failures_once = resolve_retry_failures_once(
    requested: options[:retry_failures_once],
    packages: packages,
    affected: affected,
    only_failures: only_failures,
    tags: tags,
    exclude_tags: exclude_tags
  )

  output = quiet?(options) ? StringIO.new : $stdout
  progress = options[:progress] && !quiet?(options)
  prune_artifacts_if_requested(output: output, prune_artifacts: prune_artifacts, quiet: quiet?(options))

  orchestrator = build_orchestrator(
    max_parallel: [parallel, 1].max,
    output: output,
    progress: progress
  )

  run_options = {
    parallel: parallel > 0,
    affected: affected,
    only_failures: only_failures,
    packages: packages,
    cli_args: options[:cli_args],
    provider: options[:provider],
    timeout: options[:timeout],
    tags: tags,
    exclude_tags: exclude_tags,
    verify: options[:verify]
  }

  results = run_suite_with_retry(
    orchestrator,
    run_options: run_options,
    output: output,
    retry_failures_once: retry_failures_once
  )

  if results[:total].zero?
    if only_failures
      raise Ace::Support::Cli::Error.new(
        "No failed test scenarios found in cache"
      )
    else
      raise Ace::Support::Cli::Error.new("No tests found to run")
    end
  end

  # Exit with error if any test failed
  if results[:failed] > 0 || results[:errors] > 0
    failed_count = results[:failed] + results[:errors]
    raise Ace::Support::Cli::Error.new(
      results[:retry_attempted] ? "#{failed_count} test(s) failed or errored after retry" : "#{failed_count} test(s) failed or errored"
    )
  end

  results
end