Skip to content

Commit 20a2cd5

Browse files
committed
Add an mspec configuration for running CAPI tests with handle checks.
1 parent ea2c114 commit 20a2cd5

File tree

2 files changed

+68
-27
lines changed

2 files changed

+68
-27
lines changed

spec/handleconversion.mspec

Lines changed: 0 additions & 27 deletions
This file was deleted.

spec/nativeconversion.mspec

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
class NativeHandleChecker
3+
EXPECTED_FAILURES = {
4+
"C-API Debug function rb_debug_inspector_open creates a debug context and calls the given callback" => 2,
5+
"C-API Debug function rb_debug_inspector_frame_self_get returns self" => 2,
6+
"C-API Debug function rb_debug_inspector_frame_class_get returns the frame class" => 2,
7+
"C-API Debug function rb_debug_inspector_frame_binding_get returns the current binding" => 2,
8+
"C-API Debug function rb_debug_inspector_frame_binding_get matches the locations in rb_debug_inspector_backtrace_locations" => 2,
9+
"C-API Debug function rb_debug_inspector_frame_iseq_get returns an InstructionSequence" => 2,
10+
"C-API Debug function rb_debug_inspector_backtrace_locations returns an array of Thread::Backtrace::Location" => 2,
11+
"C-API IO function rb_io_printf calls #to_str to convert the format object to a String" => 2,
12+
"C-API IO function rb_io_printf calls #to_s to convert the object to a String" => 2,
13+
"C-API IO function rb_io_printf writes the Strings to the IO" => 4,
14+
"C-API IO function rb_io_print calls #to_s to convert the object to a String" => 1,
15+
"C-API IO function rb_io_print writes the Strings to the IO with no separator" => 3,
16+
"C-API IO function rb_io_puts calls #to_s to convert the object to a String" => 1,
17+
"C-API IO function rb_io_puts writes the Strings to the IO separated by newlines" => 3,
18+
"C-API Kernel function rb_rescue executes the passed 'rescue function' if a StandardError exception is raised" => 3,
19+
"C-API Kernel function rb_rescue passes the user supplied argument to the 'rescue function' if a StandardError exception is raised" => 4,
20+
"C-API Kernel function rb_rescue passes the raised exception to the 'rescue function' if a StandardError exception is raised" => 2,
21+
"C-API Kernel function rb_rescue raises an exception if any exception is raised inside the 'rescue function'" => 1,
22+
"C-API Kernel function rb_rescue makes $! available only during the 'rescue function' execution" => 1,
23+
"CApiObject rb_obj_call_init sends #initialize" => 2,
24+
"C-API String function rb_sprintf formats a string VALUE using to_s if sign not specified in format" => 1,
25+
"C-API String function rb_sprintf formats a string VALUE using inspect if sign specified in format" => 1,
26+
"C-API String function rb_sprintf formats a TrueClass VALUE as `TrueClass` if sign not specified in format" => 1,
27+
"C-API String function rb_sprintf truncates a VALUE string to a supplied precision if that is shorter than the VALUE string" => 1,
28+
"C-API String function rb_sprintf does not truncates a VALUE string to a supplied precision if that is longer than the VALUE string" => 1,
29+
"C-API String function rb_sprintf pads a VALUE string to a supplied width if that is longer than the VALUE string" => 1,
30+
"C-API String function rb_sprintf can format a string VALUE as a pointer and gives the same output as sprintf in C" => 1,
31+
"C-API String function rb_string_value_cstr returns a non-null pointer for a simple string" => 1,
32+
"C-API String function rb_string_value_cstr returns a non-null pointer for a UTF-16 string" => 1,
33+
"C-API String function rb_string_value_cstr raises an error if a string contains a null" => 1,
34+
"C-API String function rb_string_value_cstr raises an error if a UTF-16 string contains a null" => 1,
35+
"CApiWrappedTypedStruct throws an exception for a wrong type" => 1,
36+
"C-API Util function rb_scan_args assigns Hash arguments" => 1,
37+
"C-API Util function rb_scan_args assigns required and Hash arguments" => 1,
38+
"C-API Util function rb_scan_args assigns required, optional, splat, post-splat, Hash and block arguments" => 1,
39+
"C-API Util function rb_get_kwargs extracts required arguments in the order requested" => 2,
40+
"C-API Util function rb_get_kwargs extracts required and optional arguments in the order requested" => 1,
41+
"C-API Util function rb_get_kwargs raises an error if a required argument is not in the hash" => 1,
42+
"Native handle conversion converts all elements to native handles when memcpying an RARRAY_PTR" => 1000,
43+
}
44+
45+
def register
46+
MSpec.register :before, self
47+
MSpec.register :passed, self
48+
end
49+
50+
def unregister
51+
MSpec.unregister :before, self
52+
MSpec.unregister :passed, self
53+
end
54+
55+
def before(state)
56+
@start_count = Truffle::Debug.cexts_to_native_count
57+
end
58+
59+
def passed(state, example)
60+
(Truffle::Debug.cexts_to_native_count - @start_count).should == (EXPECTED_FAILURES[state.description] || 0)
61+
end
62+
end
63+
64+
begin
65+
checker = NativeHandleChecker.new
66+
checker.register
67+
load File.expand_path('../truffleruby.mspec', __FILE__)
68+
end

0 commit comments

Comments
 (0)