Class: Crucible::Tests::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/executor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, client2 = nil) ⇒ Executor

Returns a new instance of Executor.



5
6
7
8
9
10
# File 'lib/executor.rb', line 5

def initialize(client, client2=nil)
  @client = client
  @client2 = client2
  @suite_engine = SuiteEngine.new(@client, @client2)
  @testscript_engine = TestScriptEngine.new(@client, @client2)
end

Class Method Details

.list_all(multiserver = false, metadata = false) ⇒ Object



26
27
28
29
# File 'lib/executor.rb', line 26

def self.list_all(multiserver=false, =false)
  list = SuiteEngine.list_all().merge TestScriptEngine.list_all()
  list.select {|key,value| value['multiserver'] == multiserver}
end

Instance Method Details

#execute(test) ⇒ Object



12
13
14
# File 'lib/executor.rb', line 12

def execute(test)
  test.execute
end

#execute_allObject



16
17
18
19
20
21
22
23
24
# File 'lib/executor.rb', line 16

def execute_all
  results = {}
  self.tests.each do |test|
    # TODO: Do we want to separate out multiserver tests?
    next if test.multiserver
    results.merge! execute(test)
  end
  results
end

#extract_metadata_from_test(key) ⇒ Object

finds a test from the given key and extracts only metadata into a hash



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/executor.rb', line 42

def (key)
  test = find_test(key)
   = test.(true)
   = {}
  BaseTest::METADATA_FIELDS.each do |field|
    field_hash = {}
    .each { |tm| field_hash[tm[:test_method]] = tm[field] }
    [field] = field_hash
  end
  
end

#find_test(key) ⇒ Object

finds a test by class name for suites, and by filename for testscript



37
38
39
# File 'lib/executor.rb', line 37

def find_test(key)
  @suite_engine.find_test(key) || @testscript_engine.find_test(key)
end

#testsObject



31
32
33
34
# File 'lib/executor.rb', line 31

def tests
  tests = @suite_engine.tests.concat @testscript_engine.tests
  tests.sort{|t1,t2| t1.id <=> t2.id }
end