Class: Beaker::DSL::TestTagging::PlatformTagConfiner

Inherits:
Object
  • Object
show all
Defined in:
lib/beaker/dsl/test_tagging.rb

Instance Method Summary collapse

Constructor Details

#initialize(platform_tag_confines_array) ⇒ PlatformTagConfiner

Note:

PlatformTagConfines objects come in the form [

{
  :platform => <platform-regex>,
  :tag_reason_hash => {
    <tag> => <reason to confine>,
    <tag> => <reason to confine>,
    ...etc...
  }
}

]

Constructs the PlatformTagConfiner, transforming the user format

into the internal structure for use by Beaker itself.

Internally, we want to turn tag matches into platform
  confine statements. So a better internal structure would
  be something of the form:
  {
    <tag> => [{
      :platform => <platform-regex>,
      :reason => <reason to confine>,
      :type => :except,
    }, ... ]
  }

Parameters:

  • platform_tag_confines_array (Array<Hash{Symbol=>Object}>)

    The array of PlatformTagConfines objects that specify how these confines should behave. See the note below for more info



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/beaker/dsl/test_tagging.rb', line 111

def initialize(platform_tag_confines_array)
  platform_tag_confines_array ||= []
  @tag_confine_details_hash = {}
  platform_tag_confines_array.each do |entry|
    entry[:tag_reason_hash].keys.each do |tag|
      @tag_confine_details_hash[tag] ||= []
      log_msg = "Tag '#{tag}' found, confining: except platforms "
      log_msg << "matching regex '#{entry[:platform]}'. Reason: "
      log_msg << "'#{entry[:tag_reason_hash][tag]}'"
      @tag_confine_details_hash[tag] << {
        :platform_regex => entry[:platform],
        :log_message => log_msg,
        :type => :except,
      }
    end
  end
end

Instance Method Details

#confine_details(tags) ⇒ Array<Hash{Symbol=>Object}>

Gets the confine details needed for a set of tags

Parameters:

  • tags (Array<String>)

    Tags of the given test

Returns:

  • (Array<Hash{Symbol=>Object}>)

    an array of Confine details hashes, which are hashes of symbols to their properties, which are objects of various kinds, depending on the key



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/beaker/dsl/test_tagging.rb', line 137

def confine_details(tags)
  tags ||= []
  details = []
  tags.each do |tag|
    tag_confine_array = @tag_confine_details_hash[tag]
    next if tag_confine_array.nil?

    details.push(*tag_confine_array)
    # tag_confine_array.each do |confine_details|
    #   details << confine_details
    # end
  end
  details
end