This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,13 @@ def publish(event, *args)
32
32
# parent process.
33
33
# @private
34
34
class Channel
35
+ MARSHAL_DUMP_ENCODING = Marshal . dump ( "" ) . encoding
36
+
35
37
def initialize
36
38
@read_io , @write_io = IO . pipe
39
+
40
+ # Ensure the pipe is able to send any content produced by Marshal.dump
41
+ @write_io . set_encoding MARSHAL_DUMP_ENCODING
37
42
end
38
43
39
44
def send ( message )
Original file line number Diff line number Diff line change @@ -36,5 +36,39 @@ def foo(notification); end
36
36
37
37
expect ( channel . receive ) . to eq :value_from_child
38
38
end
39
+
40
+ describe "with UTF-8 encoding set (eg. Rails)" do
41
+ around ( :each ) do |example |
42
+ old_external = old_internal = nil
43
+
44
+ ignoring_warnings do
45
+ old_external , Encoding . default_external = Encoding . default_external , Encoding ::UTF_8
46
+ old_internal , Encoding . default_internal = Encoding . default_internal , Encoding ::UTF_8
47
+ end
48
+
49
+ example . run
50
+
51
+ ignoring_warnings do
52
+ Encoding . default_external = old_external
53
+ Encoding . default_internal = old_internal
54
+ end
55
+ end
56
+
57
+ it "successfully sends binary data" do
58
+ channel = Bisect ::Channel . new
59
+ expect { channel . send ( "\xF8 " ) } . not_to raise_error
60
+ end
61
+
62
+ it "supports sending binary data from a child process back to the parent" do
63
+ channel = Bisect ::Channel . new
64
+
65
+ in_sub_process do
66
+ channel . send ( "\xF8 " )
67
+ end
68
+
69
+ expect ( channel . receive ) . to eq ( "\xF8 " )
70
+ end
71
+ end
72
+
39
73
end
40
74
end
You can’t perform that action at this time.
0 commit comments