Class: Qunit::Runner
- Inherits:
-
Object
- Object
- Qunit::Runner
- Defined in:
- lib/qunit/runner.rb,
lib/qunit/runner/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#should_exit ⇒ Object
readonly
Returns the value of attribute should_exit.
-
#test_url ⇒ Object
readonly
Returns the value of attribute test_url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Runner
constructor
A new instance of Runner.
- #run(load_timeout = 10000) ⇒ Object
- #safe_kill(pid) ⇒ Object
Constructor Details
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
12 13 14 |
# File 'lib/qunit/runner.rb', line 12 def exit_status @exit_status end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/qunit/runner.rb', line 14 def logger @logger end |
#should_exit ⇒ Object (readonly)
Returns the value of attribute should_exit.
11 12 13 |
# File 'lib/qunit/runner.rb', line 11 def should_exit @should_exit end |
#test_url ⇒ Object (readonly)
Returns the value of attribute test_url.
13 14 15 |
# File 'lib/qunit/runner.rb', line 13 def test_url @test_url end |
Instance Method Details
#run(load_timeout = 10000) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/qunit/runner.rb', line 25 def run(load_timeout = 10000) root = File.dirname(File.dirname(__FILE__)) qunit_bridge = File.join root, 'vendor', 'js', 'qunit_bridge.js' phantom_bridge = File.join root, 'vendor', 'js', 'phantom_bridge.js' opts = { timeout: load_timeout, inject: qunit_bridge } cmd = Shellwords.join [ 'phantomjs', '--load-images=false', phantom_bridge, '/dev/stdout', @test_url, opts.to_json ] Open3.popen3(cmd) do |i, o, e, t| i.close begin while line = o.gets and !@should_exit @should_exit, @exit_status = @parser.parse line end safe_kill t.pid rescue Exception safe_kill t.pid raise end end exit @exit_status || 1 end |
#safe_kill(pid) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/qunit/runner.rb', line 57 def safe_kill(pid) begin Process.kill("KILL", pid) true rescue false end end |