Method: OpenC3::Suite#run_group

Defined in:
lib/openc3/script/suite.rb

#run_group(group_class, internal = false, &block) ⇒ Object

Run a specific group



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/openc3/script/suite.rb', line 158

def run_group(group_class, internal = false, &block)
  ScriptResult.suite = name() unless internal

  # Determine if this group_class is in the plan and the number of scripts associated with this group_class
  in_plan = false
  num_scripts = 0
  @plans.each do |plan_type, plan_group_class, plan_script|
    if plan_type == :GROUP and group_class == plan_group_class
      in_plan = true
    end
    if (plan_type == :GROUP_SETUP and group_class == plan_group_class) or
       (plan_type == :GROUP_TEARDOWN and group_class == plan_group_class) or
       (plan_script and group_class == plan_group_class)
      num_scripts += 1
    end
  end

  if in_plan
    ScriptStatus.instance.total = group_class.get_num_scripts() unless internal
    results = @scripts[group_class].run(&block)
  else
    results = []
    ScriptStatus.instance.total = num_scripts unless internal

    # Run each setup, teardown, or script associated with this group_class in the order
    # defined in the plan
    @plans.each do |plan_type, plan_group_class, plan_script|
      if plan_group_class == group_class
        case plan_type
        when :SCRIPT
          result = run_script(plan_group_class, plan_script, true)
          results << result
          yield result if block_given?
        when :GROUP_SETUP
          result = run_group_setup(plan_group_class, true)
          if result
            results << result
            yield result if block_given?
          end
        when :GROUP_TEARDOWN
          result = run_group_teardown(plan_group_class, true)
          if result
            results << result
            yield result if block_given?
          end
        end
      end
    end
  end

  ScriptResult.suite = nil unless internal
  return results
end