Class: Grntest::Worker
- Inherits:
-
Object
- Object
- Grntest::Worker
- Defined in:
- lib/grntest/worker.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#suite_name ⇒ Object
readonly
Returns the value of attribute suite_name.
-
#test_name ⇒ Object
readonly
Returns the value of attribute test_name.
-
#test_script_path ⇒ Object
readonly
Returns the value of attribute test_script_path.
-
#test_suites_rusult ⇒ Object
readonly
Returns the value of attribute test_suites_rusult.
-
#tester ⇒ Object
readonly
Returns the value of attribute tester.
Instance Method Summary collapse
-
#initialize(id, tester, test_suites_result, reporter) ⇒ Worker
constructor
A new instance of Worker.
- #interrupt ⇒ Object
- #interruptted? ⇒ Boolean
- #on_test_failure(result) ⇒ Object
- #on_test_finish(result) ⇒ Object
- #on_test_leak(result) ⇒ Object
- #on_test_no_check(result) ⇒ Object
- #on_test_omission(result) ⇒ Object
- #on_test_start ⇒ Object
- #on_test_success(result) ⇒ Object
- #run(queue) ⇒ Object
Constructor Details
#initialize(id, tester, test_suites_result, reporter) ⇒ Worker
Returns a new instance of Worker.
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/grntest/worker.rb', line 68 def initialize(id, tester, test_suites_result, reporter) @id = id @tester = tester @test_suites_result = test_suites_result @reporter = reporter @suite_name = nil @test_script_path = nil @test_name = nil @interruptted = false @status = "not running" @result = WorkerResult.new end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
66 67 68 |
# File 'lib/grntest/worker.rb', line 66 def id @id end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
66 67 68 |
# File 'lib/grntest/worker.rb', line 66 def reporter @reporter end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
67 68 69 |
# File 'lib/grntest/worker.rb', line 67 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
67 68 69 |
# File 'lib/grntest/worker.rb', line 67 def status @status end |
#suite_name ⇒ Object (readonly)
Returns the value of attribute suite_name.
67 68 69 |
# File 'lib/grntest/worker.rb', line 67 def suite_name @suite_name end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name.
67 68 69 |
# File 'lib/grntest/worker.rb', line 67 def test_name @test_name end |
#test_script_path ⇒ Object (readonly)
Returns the value of attribute test_script_path.
67 68 69 |
# File 'lib/grntest/worker.rb', line 67 def test_script_path @test_script_path end |
#test_suites_rusult ⇒ Object (readonly)
Returns the value of attribute test_suites_rusult.
66 67 68 |
# File 'lib/grntest/worker.rb', line 66 def test_suites_rusult @test_suites_rusult end |
#tester ⇒ Object (readonly)
Returns the value of attribute tester.
66 67 68 |
# File 'lib/grntest/worker.rb', line 66 def tester @tester end |
Instance Method Details
#interrupt ⇒ Object
81 82 83 |
# File 'lib/grntest/worker.rb', line 81 def interrupt @interruptted = true end |
#interruptted? ⇒ Boolean
85 86 87 |
# File 'lib/grntest/worker.rb', line 85 def interruptted? @interruptted end |
#on_test_failure(result) ⇒ Object
133 134 135 136 137 |
# File 'lib/grntest/worker.rb', line 133 def on_test_failure(result) @status = "failed" @result.on_test_failure(test_name) @reporter.on_test_failure(self, result) end |
#on_test_finish(result) ⇒ Object
157 158 159 160 161 162 |
# File 'lib/grntest/worker.rb', line 157 def on_test_finish(result) @result.on_test_finish @reporter.on_test_finish(self, result) @test_script_path = nil @test_name = nil end |
#on_test_leak(result) ⇒ Object
139 140 141 142 143 |
# File 'lib/grntest/worker.rb', line 139 def on_test_leak(result) @status = "leaked(#{result.n_leaked_objects})" @result.on_test_leak(test_name) @reporter.on_test_leak(self, result) end |
#on_test_no_check(result) ⇒ Object
151 152 153 154 155 |
# File 'lib/grntest/worker.rb', line 151 def on_test_no_check(result) @status = "not checked" @result.on_test_no_check @reporter.on_test_no_check(self, result) end |
#on_test_omission(result) ⇒ Object
145 146 147 148 149 |
# File 'lib/grntest/worker.rb', line 145 def on_test_omission(result) @status = "omitted" @result.on_test_omission @reporter.on_test_omission(self, result) end |
#on_test_start ⇒ Object
121 122 123 124 125 |
# File 'lib/grntest/worker.rb', line 121 def on_test_start @status = "running" @test_result = nil @reporter.on_test_start(self) end |
#on_test_success(result) ⇒ Object
127 128 129 130 131 |
# File 'lib/grntest/worker.rb', line 127 def on_test_success(result) @status = "passed" @result.on_test_success @reporter.on_test_success(self, result) end |
#run(queue) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/grntest/worker.rb', line 89 def run(queue) succeeded = true @result.measure do @reporter.on_worker_start(self) catch do |tag| loop do suite_name, test_script_path, test_name = queue.pop break if test_script_path.nil? unless @suite_name == suite_name @reporter.on_suite_finish(self) if @suite_name @suite_name = suite_name @reporter.on_suite_start(self) end @test_script_path = test_script_path @test_name = test_name runner = TestRunner.new(@tester, self) succeeded = false unless runner.run break if interruptted? end @status = "finished" @reporter.on_suite_finish(@suite_name) if @suite_name @suite_name = nil end end @reporter.on_worker_finish(self) succeeded end |