Class: Ace::Test::EndToEndRunner::Molecules::PipelineSandboxBuilder

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

Overview

Builds deterministic sandbox state for standalone execution.

Instance Method Summary collapse

Constructor Details

#initialize(config_root: Dir.pwd, package_copy: nil, runtime_builder: nil, config: nil) ⇒ PipelineSandboxBuilder

Returns a new instance of PipelineSandboxBuilder.

Parameters:

  • config_root (String) (defaults to: Dir.pwd)

    Project root used for provider symlink/bin path



15
16
17
18
19
20
21
22
23
# File 'lib/ace/test/end_to_end_runner/molecules/pipeline_sandbox_builder.rb', line 15

def initialize(config_root: Dir.pwd, package_copy: nil, runtime_builder: nil, config: nil)
  @config_root = File.expand_path(config_root)
  @config = config || Molecules::ConfigLoader.load
  @package_copy = package_copy || Ace::TestSupport::SandboxPackageCopy.new(source_root: @config_root)
  @runtime_builder = runtime_builder || Molecules::SandboxRuntimeBuilder.new(
    source_root: @config_root,
    ruby_version: @config.dig("sandbox", "ruby_version") || Molecules::ConfigLoader.default_sandbox_ruby_version
  )
end

Instance Method Details

#build(scenario:, sandbox_path:, test_cases: nil) ⇒ Hash

Returns Environment variables for subprocess execution.

Parameters:

  • scenario (Models::TestScenario)
  • sandbox_path (String)
  • test_cases (Array<String>, nil) (defaults to: nil)

    Optional TC filter

Returns:

  • (Hash)

    Environment variables for subprocess execution



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ace/test/end_to_end_runner/molecules/pipeline_sandbox_builder.rb', line 29

def build(scenario:, sandbox_path:, test_cases: nil)
  sandbox_path = File.expand_path(sandbox_path)
  FileUtils.mkdir_p(sandbox_path)
  FileUtils.mkdir_p(File.join(sandbox_path, ".ace-local", "e2e"))
  FileUtils.mkdir_p(File.join(sandbox_path, "reports"))

  initialize_git_repo(sandbox_path)
  package_copy_result = ensure_package_available(scenario.package, sandbox_path)
  sync_protocol_sources(sandbox_path)
  runtime_result = @runtime_builder.prepare(
    sandbox_root: sandbox_path,
    env: package_copy_result[:env],
    tool_names: scenario.requires.fetch("tools", [])
  )
  link_provider_configs(sandbox_path)
  create_result_directories(scenario, sandbox_path, test_cases: test_cases)
  run_default_bootstrap(scenario, sandbox_path, runtime_result[:env])
  verify_tool_access(scenario, sandbox_path, runtime_result[:env])

  runtime_result[:env]
end

#prepare_existing_sandbox(scenario:, sandbox_path:, test_cases: nil) ⇒ Hash

Prepare only the runner/verifier layout for a sandbox that was already created by the deterministic setup path.

This must not mutate tracked sandbox contents by copying packages, syncing protocol sources, or replacing config directories with symlinks after the scenario setup has already established git state.

Parameters:

  • scenario (Models::TestScenario)
  • sandbox_path (String)
  • test_cases (Array<String>, nil) (defaults to: nil)

    Optional TC filter

Returns:

  • (Hash)

    Additional environment variables (none required)



62
63
64
65
66
67
68
69
# File 'lib/ace/test/end_to_end_runner/molecules/pipeline_sandbox_builder.rb', line 62

def prepare_existing_sandbox(scenario:, sandbox_path:, test_cases: nil)
  sandbox_path = File.expand_path(sandbox_path)
  FileUtils.mkdir_p(sandbox_path)
  FileUtils.mkdir_p(File.join(sandbox_path, ".ace-local", "e2e"))
  FileUtils.mkdir_p(File.join(sandbox_path, "reports"))
  create_result_directories(scenario, sandbox_path, test_cases: test_cases)
  {}
end

#sync_protocol_sources_into(sandbox_path) ⇒ void

This method returns an undefined value.

Sync protocol source manifests and backing directories into a prepared sandbox before deterministic setup runs.

This is safe before setup because no scenario-owned git baseline has been established yet. It is intentionally separate from prepare_existing_sandbox so the post-setup pipeline path remains non-mutating.

Parameters:

  • sandbox_path (String)


81
82
83
# File 'lib/ace/test/end_to_end_runner/molecules/pipeline_sandbox_builder.rb', line 81

def sync_protocol_sources_into(sandbox_path)
  sync_protocol_sources(File.expand_path(sandbox_path))
end