Class: Ace::Test::EndToEndRunner::Molecules::SandboxRuntimeBuilder

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

Overview

Builds a sandbox-local Ruby/Bundler runtime for E2E execution.

Constant Summary collapse

DEFAULT_RUBY_VERSION =
"3.4.9"
RESERVED_ENV_KEYS =
%w[
  PROJECT_ROOT_PATH
  ACE_E2E_SOURCE_ROOT
  ACE_CONFIG_PATH
  BUNDLE_GEMFILE
  BUNDLE_APP_CONFIG
  BUNDLE_USER_HOME
  BUNDLE_USER_CACHE
  BUNDLE_USER_CONFIG
  BUNDLE_PATH
  BUNDLE_BIN
  BUNDLE_DISABLE_SHARED_GEMS
  BUNDLER_VERSION
  GEM_HOME
  GEM_PATH
  RUBYOPT
  RUBYLIB
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(source_root:, ruby_version: nil, command_runner: nil) ⇒ SandboxRuntimeBuilder

Returns a new instance of SandboxRuntimeBuilder.



32
33
34
35
36
# File 'lib/ace/test/end_to_end_runner/molecules/sandbox_runtime_builder.rb', line 32

def initialize(source_root:, ruby_version: nil, command_runner: nil)
  @source_root = File.expand_path(source_root)
  @ruby_version = (ruby_version || DEFAULT_RUBY_VERSION).to_s.strip
  @command_runner = command_runner || method(:capture3)
end

Instance Method Details

#prepare(sandbox_root:, env: {}, tool_names: nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ace/test/end_to_end_runner/molecules/sandbox_runtime_builder.rb', line 38

def prepare(sandbox_root:, env: {}, tool_names: nil)
  sandbox_root = File.expand_path(sandbox_root)
  runtime_root = File.join(sandbox_root, ".ace-local", "e2e-runtime")
  FileUtils.mkdir_p(runtime_root)

  runtime_env = build_runtime_env(sandbox_root, runtime_root, env)
  ensure_runtime_dirs(runtime_env)
  write_runtime_gemfile(runtime_root)
  write_command_shims(runtime_root, tool_names)
  install_runtime!(runtime_root, runtime_env)

  {
    runtime_root: runtime_root,
    env: runtime_env
  }
end