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.
-
#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.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/grntest/worker.rb', line 66 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.
64 65 66 |
# File 'lib/grntest/worker.rb', line 64 def id @id end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
64 65 66 |
# File 'lib/grntest/worker.rb', line 64 def reporter @reporter end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
65 66 67 |
# File 'lib/grntest/worker.rb', line 65 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
65 66 67 |
# File 'lib/grntest/worker.rb', line 65 def status @status end |
#suite_name ⇒ Object (readonly)
Returns the value of attribute suite_name.
65 66 67 |
# File 'lib/grntest/worker.rb', line 65 def suite_name @suite_name end |
#test_name ⇒ Object (readonly)
Returns the value of attribute test_name.
65 66 67 |
# File 'lib/grntest/worker.rb', line 65 def test_name @test_name end |
#test_script_path ⇒ Object (readonly)
Returns the value of attribute test_script_path.
65 66 67 |
# File 'lib/grntest/worker.rb', line 65 def test_script_path @test_script_path end |
#tester ⇒ Object (readonly)
Returns the value of attribute tester.
64 65 66 |
# File 'lib/grntest/worker.rb', line 64 def tester @tester end |
Instance Method Details
#interrupt ⇒ Object
79 80 81 |
# File 'lib/grntest/worker.rb', line 79 def interrupt @interruptted = true end |
#interruptted? ⇒ Boolean
83 84 85 |
# File 'lib/grntest/worker.rb', line 83 def interruptted? @interruptted end |
#on_test_failure(result) ⇒ Object
135 136 137 138 139 |
# File 'lib/grntest/worker.rb', line 135 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
163 164 165 166 |
# File 'lib/grntest/worker.rb', line 163 def on_test_finish(result) @result.on_test_finish @reporter.on_test_finish(self, result) end |
#on_test_leak(result) ⇒ Object
141 142 143 144 145 |
# File 'lib/grntest/worker.rb', line 141 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
157 158 159 160 161 |
# File 'lib/grntest/worker.rb', line 157 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
147 148 149 150 151 152 153 154 155 |
# File 'lib/grntest/worker.rb', line 147 def on_test_omission(result) @status = "omitted" @result.on_test_omission if @tester.suppress_omit_log? @reporter.on_test_omission_suppressed(self, result) else @reporter.on_test_omission(self, result) end end |
#on_test_start ⇒ Object
123 124 125 126 127 |
# File 'lib/grntest/worker.rb', line 123 def on_test_start @status = "running" @test_result = nil @reporter.on_test_start(self) end |
#on_test_success(result) ⇒ Object
129 130 131 132 133 |
# File 'lib/grntest/worker.rb', line 129 def on_test_success(result) @status = "passed" @result.on_test_success @reporter.on_test_success(self, result) end |
#run(queue) ⇒ Object
87 88 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 120 121 |
# File 'lib/grntest/worker.rb', line 87 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 unless run_test(test_script_path, test_name) succeeded = false end break if interruptted? if @tester.stop_on_failure? and @test_suites_result.have_failure? break end end @status = "finished" @reporter.on_suite_finish(@suite_name) if @suite_name @suite_name = nil end end @reporter.on_worker_finish(self) succeeded end |