Module: CemAcpt::Platform

Extended by:
Logging
Defined in:
lib/cem_acpt/platform.rb,
lib/cem_acpt/platform/base.rb,
lib/cem_acpt/platform/base/cmd.rb

Overview

CemAcpt::Platform manages creating and configring platform specific objects for the acceptance test suites.

Defined Under Namespace

Modules: Gcp Classes: Base, CmdBase, Error

Constant Summary collapse

PLATFORM_DIR =
File.expand_path(File.join(__dir__, 'platform'))

Class Method Summary collapse

Methods included from Logging

current_log_config, current_log_config, current_log_format, current_log_level, current_log_level, included, logger, new_log_config, new_log_config, new_log_formatter, new_log_level, new_log_level

Class Method Details

.get(platform) ⇒ Object

Returns an un-initialized platform specific Class of the given platform.

Parameters:

  • platform (String)

    the name of the platform

Raises:



37
38
39
40
41
# File 'lib/cem_acpt/platform.rb', line 37

def get(platform)
  raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform)

  platform_class(platform)
end

.use(platform, config, test_data, local_port_allocator) ⇒ Object

Creates a new platform specific object of the given platform for each item in the test data.

Parameters:

  • platform (String)

    the name of the platform

  • config (CemAcpt::Config)

    the config object

  • test_data (Hash)

    the test data

  • local_port_allocator (CemAcpt::LocalPortAllocator)

    the local port allocator

Raises:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cem_acpt/platform.rb', line 23

def use(platform, config, test_data, local_port_allocator)
  raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform)
  raise Error, 'test_data must be an Array' unless test_data.is_a?(Array)

  logger.info "Using #{platform} for #{test_data.length} tests..."
  test_data.each_with_object([]) do |single_test_data, ary|
    local_port = local_port_allocator.allocate
    logger.debug("Allocated local port #{local_port} for test #{single_test_data[:test_name]}")
    ary << new_platform_object(platform, config, single_test_data, local_port)
  end
end