152
153
154
155
156
157
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
|
# File 'lib/beaker/subcommand.rb', line 152
def exec(resource = nil)
if options[:help]
invoke :help, [], ["exec"]
return
end
@cli.parse_options
@cli.initialize_network_manager
if !resource
@cli.execute!
return
end
beaker_suites = %i[pre_suite tests post_suite pre_cleanup]
resources = resource.split(',')
paths = resources.map { |r| Pathname(r) }
if paths.all?(&:exist?)
beaker_suites.each do |suite|
@cli.options[suite] = []
end
@cli.options[:tests] = paths.map do |path|
if path.directory?
Dir.glob("#{path}/**/*.rb")
else
path.to_s
end
end.flatten
elsif resources.all? { |r| /^(pre-suite|tests|post-suite|pre-cleanup)$/.match?(r) }
beaker_suites.each do |suite|
@cli.options[suite] = [] unless resource.tr('-', '_').match(suite.to_s)
end
else
raise ArgumentError, "Unable to parse #{resource} with beaker exec"
end
@cli.execute!
return unless options['preserve-state']
@cli.logger.notify 'updating HOSTS key in subcommand_options'
hosts = SubcommandUtil.sanitize_options_for_save(@cli.combined_instance_and_options_hosts)
options_storage = YAML::Store.new(SubcommandUtil::SUBCOMMAND_OPTIONS)
options_storage.transaction do
options_storage['HOSTS'] = hosts
end
end
|