Class: Ace::Test::EndToEndRunner::Molecules::IntegrationRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/test/end_to_end_runner/molecules/integration_runner.rb

Overview

Runs deterministic preflight tests inside a sandboxed package copy.

Instance Method Summary collapse

Constructor Details

#initialize(base_dir: Dir.pwd, package_copy: nil) ⇒ IntegrationRunner

Returns a new instance of IntegrationRunner.



14
15
16
17
# File 'lib/ace/test/end_to_end_runner/molecules/integration_runner.rb', line 14

def initialize(base_dir: Dir.pwd, package_copy: nil)
  @base_dir = File.expand_path(base_dir)
  @package_copy = package_copy || Ace::TestSupport::SandboxPackageCopy.new(source_root: @base_dir)
end

Instance Method Details

#run(package:, files:, timestamp:, output: $stdout) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ace/test/end_to_end_runner/molecules/integration_runner.rb', line 19

def run(package:, files:, timestamp:, output: $stdout)
  return nil if files.nil? || files.empty?

  started_at = Time.now
  sandbox_root = File.join(@base_dir, ".ace-local", "test-e2e", "#{timestamp}-#{package}-preflight")
  FileUtils.mkdir_p(sandbox_root)

  package_copy_result = @package_copy.prepare(package_name: package, sandbox_root: sandbox_root)
  package_root = resolve_package_root(sandbox_root, package)
  env = package_copy_result[:env] || {}

  test_cases = files.map do |file|
    run_file(package_root, file, env, output)
  end

  status = if test_cases.any? { |tc| tc[:status] == "error" }
    "error"
  elsif test_cases.any? { |tc| tc[:status] == "fail" }
    "fail"
  else
    "pass"
  end

  Models::TestResult.new(
    test_id: "PREFLIGHT",
    status: status,
    test_cases: test_cases,
    summary: preflight_summary(status, test_cases),
    started_at: started_at,
    completed_at: Time.now,
    metadata: {
      phase: "preflight",
      package: package,
      sandbox_root: sandbox_root
    }
  )
end