ruby-qa/lib/manager.rb

57 lines
1.1 KiB
Ruby
Raw Normal View History

2024-06-09 22:16:20 -04:00
module RubyQA
class Manager
attr_reader :resources, :hosts
2024-06-09 22:16:20 -04:00
@@tests = Array.new
@@hosts = Array.new
2024-06-09 22:16:20 -04:00
def self.tests
@@tests
2024-06-09 22:16:20 -04:00
end
def self.hosts
@@hosts
end
def self.add_host(host)
@@hosts << host
2024-06-09 22:16:20 -04:00
register_resources(host)
update_resources(host)
end
def self.register_resources (host)
2024-06-09 22:16:20 -04:00
Resource.all_resources.each do |resource|
host.add_resource(resource)
end
end
def self.update_resources (host)
2024-06-09 22:16:20 -04:00
host.update_resources
end
def self.new_test(name, options={}, &test_proc)
2024-07-17 13:14:28 -04:00
if not options.has_key? :disabled
@@tests << Test.new(name, **options, &test_proc)
elsif options[:disabled] != true
@@tests << Test.new(name, **options, &test_proc)
end
2024-06-09 22:16:20 -04:00
end
def self.run_tests
@@hosts.each do |host|
2024-06-09 22:16:20 -04:00
tests = @@tests.select{|test| test.valid_host(host)}
tests.each do |test|
test.run(host)
end
end
end
def self.report (template = nil)
if template
puts template.result(binding)
else
puts @@tests.map(&:report).join("\n")
end
2024-06-09 22:16:20 -04:00
end
end
end