Skip to content

Commit 690e88e

Browse files
committed
FIX handle missing fiddle/import more gracefully
Thanks for the bug report and testing, Willie!
1 parent 34bcd1c commit 690e88e

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/qa/runner-assets/ruby/shared.rb

+31-23
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,41 @@
33
module Qa; end
44

55
module Qa::Binding
6-
# From https://github.com/banister/binding_of_caller/issues/57
7-
# Thanks to Steve Shreeve <[email protected]>
8-
9-
require 'fiddle/import'
10-
11-
extend Fiddle::Importer
6+
begin
7+
# From https://github.com/banister/binding_of_caller/issues/57
8+
# Thanks to Steve Shreeve <[email protected]>
9+
10+
require 'fiddle/import'
11+
rescue LoadError
12+
class << self
13+
def callers
14+
[]
15+
end
16+
end
17+
else
18+
extend Fiddle::Importer
1219

13-
dlload Fiddle.dlopen(nil)
20+
dlload Fiddle.dlopen(nil)
1421

15-
DebugStruct = struct [
16-
"void* thread",
17-
"void* frame",
18-
"void* backtrace",
19-
"void* contexts",
20-
"long backtrace_size"
21-
]
22+
DebugStruct = struct [
23+
"void* thread",
24+
"void* frame",
25+
"void* backtrace",
26+
"void* contexts",
27+
"long backtrace_size"
28+
]
2229

23-
extern "void* rb_debug_inspector_open(void*, void*)"
24-
bind("void* callback(void*, void*)") do |ptr, _|
25-
DebugStruct.new(ptr).contexts
26-
end
30+
extern "void* rb_debug_inspector_open(void*, void*)"
31+
bind("void* callback(void*, void*)") do |ptr, _|
32+
DebugStruct.new(ptr).contexts
33+
end
2734

28-
class << self
29-
def callers
30-
list_ptr = rb_debug_inspector_open(self['callback'], nil)
31-
list = list_ptr.to_value
32-
list.drop(4).map {|ary| ary[2] } # grab proper bindings
35+
class << self
36+
def callers
37+
list_ptr = rb_debug_inspector_open(self['callback'], nil)
38+
list = list_ptr.to_value
39+
list.drop(4).map {|ary| ary[2] } # grab proper bindings
40+
end
3341
end
3442
end
3543
end

0 commit comments

Comments
 (0)