libuv 0.11.22 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +19 -17
- data/.gitmodules +3 -3
- data/.rspec +1 -1
- data/.travis.yml +16 -16
- data/Gemfile +4 -4
- data/LICENSE +23 -23
- data/README.md +89 -89
- data/Rakefile +31 -31
- data/lib/libuv.rb +54 -54
- data/lib/libuv/async.rb +47 -47
- data/lib/libuv/check.rb +55 -55
- data/lib/libuv/dns.rb +85 -85
- data/lib/libuv/error.rb +78 -74
- data/lib/libuv/ext/ext.rb +260 -258
- data/lib/libuv/ext/platform/darwin_x64.rb +23 -23
- data/lib/libuv/ext/platform/linux.rb +7 -7
- data/lib/libuv/ext/platform/unix.rb +29 -29
- data/lib/libuv/ext/platform/windows.rb +40 -40
- data/lib/libuv/ext/tasks.rb +31 -31
- data/lib/libuv/ext/tasks/mac.rb +23 -23
- data/lib/libuv/ext/tasks/unix.rb +23 -23
- data/lib/libuv/ext/tasks/win.rb +14 -14
- data/lib/libuv/ext/types.rb +238 -238
- data/lib/libuv/file.rb +281 -269
- data/lib/libuv/filesystem.rb +232 -232
- data/lib/libuv/fs_event.rb +31 -31
- data/lib/libuv/handle.rb +85 -85
- data/lib/libuv/idle.rb +56 -56
- data/lib/libuv/loop.rb +412 -412
- data/lib/libuv/mixins/assertions.rb +23 -23
- data/lib/libuv/mixins/fs_checks.rb +60 -58
- data/lib/libuv/mixins/listener.rb +34 -34
- data/lib/libuv/mixins/net.rb +40 -40
- data/lib/libuv/mixins/resource.rb +27 -27
- data/lib/libuv/mixins/stream.rb +153 -154
- data/lib/libuv/pipe.rb +184 -203
- data/lib/libuv/prepare.rb +56 -56
- data/lib/libuv/signal.rb +51 -51
- data/lib/libuv/tcp.rb +334 -334
- data/lib/libuv/timer.rb +85 -85
- data/lib/libuv/tty.rb +37 -37
- data/lib/libuv/udp.rb +240 -240
- data/lib/libuv/version.rb +3 -3
- data/lib/libuv/work.rb +75 -75
- data/libuv.gemspec +56 -56
- data/spec/async_spec.rb +61 -60
- data/spec/cpu_spec.rb +10 -10
- data/spec/defer_spec.rb +980 -980
- data/spec/dns_spec.rb +96 -90
- data/spec/filesystem_spec.rb +270 -261
- data/spec/idle_spec.rb +56 -56
- data/spec/pipe_spec.rb +160 -160
- data/spec/tcp_spec.rb +271 -267
- metadata +64 -51
data/spec/dns_spec.rb
CHANGED
@@ -1,90 +1,96 @@
|
|
1
|
-
require 'libuv'
|
2
|
-
|
3
|
-
|
4
|
-
describe Libuv::Dns do
|
5
|
-
before :each do
|
6
|
-
@log = []
|
7
|
-
@general_failure = []
|
8
|
-
|
9
|
-
@loop = Libuv::Loop.default
|
10
|
-
@timeout = @loop.timer do
|
11
|
-
@loop.stop
|
12
|
-
@general_failure << "test timed out"
|
13
|
-
end
|
14
|
-
@timeout.start(5000)
|
15
|
-
|
16
|
-
@loop.all(@server, @client, @timeout).catch do |reason|
|
17
|
-
@general_failure << reason.inspect
|
18
|
-
p "Failed with: #{reason.message}\n#{reason.backtrace.join("\n")}\n"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should resolve localhost using IP4", :network => true do
|
23
|
-
@loop.run { |logger|
|
24
|
-
logger.progress do |level, errorid, error|
|
25
|
-
begin
|
26
|
-
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
27
|
-
rescue Exception
|
28
|
-
p 'error in logger'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
@loop.lookup('localhost').then proc { |addrinfo|
|
33
|
-
@result = addrinfo[0][0]
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
p
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@
|
60
|
-
@loop.stop
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
@
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
1
|
+
require 'libuv'
|
2
|
+
|
3
|
+
|
4
|
+
describe Libuv::Dns do
|
5
|
+
before :each do
|
6
|
+
@log = []
|
7
|
+
@general_failure = []
|
8
|
+
|
9
|
+
@loop = Libuv::Loop.default
|
10
|
+
@timeout = @loop.timer do
|
11
|
+
@loop.stop
|
12
|
+
@general_failure << "test timed out"
|
13
|
+
end
|
14
|
+
@timeout.start(5000)
|
15
|
+
|
16
|
+
@loop.all(@server, @client, @timeout).catch do |reason|
|
17
|
+
@general_failure << reason.inspect
|
18
|
+
p "Failed with: #{reason.message}\n#{reason.backtrace.join("\n")}\n"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should resolve localhost using IP4", :network => true do
|
23
|
+
@loop.run { |logger|
|
24
|
+
logger.progress do |level, errorid, error|
|
25
|
+
begin
|
26
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
27
|
+
rescue Exception
|
28
|
+
p 'error in logger'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@loop.lookup('localhost').then proc { |addrinfo|
|
33
|
+
@result = addrinfo[0][0]
|
34
|
+
@timeout.close
|
35
|
+
@loop.stop
|
36
|
+
}, proc { |err|
|
37
|
+
@general_failure << err
|
38
|
+
@timeout.close
|
39
|
+
@loop.stop
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
expect(@general_failure).to eq([])
|
44
|
+
expect(@result).to eq('127.0.0.1')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should resolve localhost using IP6", :network => true do
|
48
|
+
@loop.run { |logger|
|
49
|
+
logger.progress do |level, errorid, error|
|
50
|
+
begin
|
51
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
52
|
+
rescue Exception
|
53
|
+
p 'error in logger'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@loop.lookup('localhost', :IPv6).then proc { |addrinfo|
|
58
|
+
@result = addrinfo[0][0]
|
59
|
+
@timeout.close
|
60
|
+
@loop.stop
|
61
|
+
}, proc { |err|
|
62
|
+
@general_failure << err
|
63
|
+
@timeout.close
|
64
|
+
@loop.stop
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
expect(@general_failure).to eq([])
|
69
|
+
expect(@result).to eq('::1')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should resolve loop back" do
|
73
|
+
@loop.run { |logger|
|
74
|
+
logger.progress do |level, errorid, error|
|
75
|
+
begin
|
76
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
77
|
+
rescue Exception
|
78
|
+
p 'error in logger'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
@loop.lookup('127.0.0.1').then proc { |addrinfo|
|
83
|
+
@result = addrinfo[0][0]
|
84
|
+
@timeout.close
|
85
|
+
@loop.stop
|
86
|
+
}, proc { |err|
|
87
|
+
@general_failure << err
|
88
|
+
@timeout.close
|
89
|
+
@loop.stop
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
expect(@general_failure).to eq([])
|
94
|
+
expect(@result).to eq('127.0.0.1')
|
95
|
+
end
|
96
|
+
end
|
data/spec/filesystem_spec.rb
CHANGED
@@ -1,261 +1,270 @@
|
|
1
|
-
require 'libuv'
|
2
|
-
require 'thread'
|
3
|
-
|
4
|
-
|
5
|
-
describe Libuv::Filesystem do
|
6
|
-
before :each do
|
7
|
-
@log = []
|
8
|
-
@general_failure = []
|
9
|
-
|
10
|
-
@loop = Libuv::Loop.default
|
11
|
-
@filesystem = @loop.filesystem
|
12
|
-
@timeout = @loop.timer do
|
13
|
-
@loop.stop
|
14
|
-
@general_failure << "test timed out"
|
15
|
-
end
|
16
|
-
@timeout.start(4000)
|
17
|
-
|
18
|
-
@logger = proc { |level, errorid, error|
|
19
|
-
begin
|
20
|
-
@general_failure << "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
21
|
-
rescue Exception
|
22
|
-
@general_failure << 'error in logger'
|
23
|
-
end
|
24
|
-
}
|
25
|
-
|
26
|
-
@thefile = "test-file.txt"
|
27
|
-
|
28
|
-
@loop.all(@filesystem, @timeout).catch do |reason|
|
29
|
-
@general_failure << reason.inspect
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'directory navigation' do
|
34
|
-
it "should list the contents of a folder" do
|
35
|
-
@loop.run { |logger|
|
36
|
-
logger.progress &@logger
|
37
|
-
|
38
|
-
currentDir = Dir.pwd
|
39
|
-
listing = @filesystem.readdir(currentDir)
|
40
|
-
listing.then do |result|
|
41
|
-
@log = result
|
42
|
-
end
|
43
|
-
listing.catch do |error|
|
44
|
-
@general_failure << error
|
45
|
-
end
|
46
|
-
listing.finally do
|
47
|
-
@
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
expect(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
file.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
op
|
115
|
-
|
116
|
-
@
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
@
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
@
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
file.
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
#
|
235
|
-
@
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
#
|
244
|
-
@client.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
1
|
+
require 'libuv'
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
|
5
|
+
describe Libuv::Filesystem do
|
6
|
+
before :each do
|
7
|
+
@log = []
|
8
|
+
@general_failure = []
|
9
|
+
|
10
|
+
@loop = Libuv::Loop.default
|
11
|
+
@filesystem = @loop.filesystem
|
12
|
+
@timeout = @loop.timer do
|
13
|
+
@loop.stop
|
14
|
+
@general_failure << "test timed out"
|
15
|
+
end
|
16
|
+
@timeout.start(4000)
|
17
|
+
|
18
|
+
@logger = proc { |level, errorid, error|
|
19
|
+
begin
|
20
|
+
@general_failure << "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
21
|
+
rescue Exception
|
22
|
+
@general_failure << 'error in logger'
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
@thefile = "test-file.txt"
|
27
|
+
|
28
|
+
@loop.all(@filesystem, @timeout).catch do |reason|
|
29
|
+
@general_failure << reason.inspect
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'directory navigation' do
|
34
|
+
it "should list the contents of a folder" do
|
35
|
+
@loop.run { |logger|
|
36
|
+
logger.progress &@logger
|
37
|
+
|
38
|
+
currentDir = Dir.pwd
|
39
|
+
listing = @filesystem.readdir(currentDir)
|
40
|
+
listing.then do |result|
|
41
|
+
@log = result
|
42
|
+
end
|
43
|
+
listing.catch do |error|
|
44
|
+
@general_failure << error
|
45
|
+
end
|
46
|
+
listing.finally do
|
47
|
+
@timeout.close
|
48
|
+
@loop.stop
|
49
|
+
end
|
50
|
+
}
|
51
|
+
|
52
|
+
expect(@general_failure).to eq([])
|
53
|
+
expect((@log.length > 0)).to eq(true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'file manipulation' do
|
58
|
+
it "should create and write to a file" do
|
59
|
+
@loop.run { |logger|
|
60
|
+
logger.progress &@logger
|
61
|
+
|
62
|
+
file = @loop.file(@thefile, File::CREAT|File::WRONLY)
|
63
|
+
file.progress do
|
64
|
+
file.write('write some data to a file').then do
|
65
|
+
file.chmod(777).then do
|
66
|
+
file.close
|
67
|
+
@timeout.close
|
68
|
+
@loop.stop
|
69
|
+
@log = :success
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
file.catch do |error|
|
74
|
+
@general_failure << error
|
75
|
+
@timeout.close
|
76
|
+
file.close
|
77
|
+
@loop.stop
|
78
|
+
end
|
79
|
+
}
|
80
|
+
|
81
|
+
expect(@general_failure).to eq([])
|
82
|
+
expect(@log).to eq(:success)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should read from a file" do
|
86
|
+
@loop.run { |logger|
|
87
|
+
logger.progress &@logger
|
88
|
+
|
89
|
+
file = @loop.file(@thefile, File::RDONLY)
|
90
|
+
file.progress do
|
91
|
+
file.read(100).then do |result|
|
92
|
+
file.close
|
93
|
+
@timeout.close
|
94
|
+
@loop.stop
|
95
|
+
@log = result
|
96
|
+
end
|
97
|
+
end
|
98
|
+
file.catch do |error|
|
99
|
+
@general_failure << error
|
100
|
+
@timeout.close
|
101
|
+
file.close
|
102
|
+
@loop.stop
|
103
|
+
end
|
104
|
+
}
|
105
|
+
|
106
|
+
expect(@general_failure).to eq([])
|
107
|
+
expect(@log).to eq('write some data to a file')
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should delete a file" do
|
111
|
+
@loop.run { |logger|
|
112
|
+
logger.progress &@logger
|
113
|
+
|
114
|
+
op = @loop.filesystem.unlink(@thefile)
|
115
|
+
op.then do
|
116
|
+
@timeout.close
|
117
|
+
@loop.stop
|
118
|
+
@log = :success
|
119
|
+
end
|
120
|
+
op.catch do |error|
|
121
|
+
@general_failure << error
|
122
|
+
@timeout.close
|
123
|
+
@loop.stop
|
124
|
+
end
|
125
|
+
}
|
126
|
+
|
127
|
+
expect(@general_failure).to eq([])
|
128
|
+
expect(@log).to eq(:success)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'file streaming' do
|
133
|
+
it "should send a file over a stream", :network => true do
|
134
|
+
@loop.run { |logger|
|
135
|
+
logger.progress &@logger
|
136
|
+
|
137
|
+
@server = @loop.tcp
|
138
|
+
@client = @loop.tcp
|
139
|
+
|
140
|
+
@server.bind('127.0.0.1', 34570) do |server|
|
141
|
+
server.accept do |client|
|
142
|
+
client.progress do |data|
|
143
|
+
file = @loop.file('.rspec', File::RDONLY)
|
144
|
+
file.progress do
|
145
|
+
file.send_file(client).then(proc {
|
146
|
+
file.close
|
147
|
+
client.close
|
148
|
+
}, proc { |error|
|
149
|
+
@general_failure << error
|
150
|
+
})
|
151
|
+
end
|
152
|
+
file.catch do |error|
|
153
|
+
@general_failure << error.inspect
|
154
|
+
file.close
|
155
|
+
client.close
|
156
|
+
end
|
157
|
+
end
|
158
|
+
client.start_read
|
159
|
+
client.finally do
|
160
|
+
@timeout.close
|
161
|
+
@server.close
|
162
|
+
@loop.stop
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
# catch errors
|
167
|
+
@server.catch do |reason|
|
168
|
+
@general_failure << reason.inspect
|
169
|
+
@loop.stop
|
170
|
+
end
|
171
|
+
# start listening
|
172
|
+
@server.listen(5)
|
173
|
+
|
174
|
+
|
175
|
+
# connect client to server
|
176
|
+
@client.connect('127.0.0.1', 34570) do |client|
|
177
|
+
client.progress do |data|
|
178
|
+
@log << data
|
179
|
+
end
|
180
|
+
|
181
|
+
@client.start_read
|
182
|
+
@client.write('send file')
|
183
|
+
end
|
184
|
+
# catch errors
|
185
|
+
@client.catch do |reason|
|
186
|
+
@general_failure << reason.inspect
|
187
|
+
@server.close
|
188
|
+
@loop.stop
|
189
|
+
end
|
190
|
+
}
|
191
|
+
|
192
|
+
expect(@general_failure).to eq([])
|
193
|
+
# Windows GIT adds the carriage return
|
194
|
+
if FFI::Platform.windows?
|
195
|
+
expect(@log).to eq(["--format progress\r\n"])
|
196
|
+
else
|
197
|
+
expect(@log).to eq(["--format progress\n"])
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should send a file as a HTTP chunked response", :network => true do
|
202
|
+
@loop.run { |logger|
|
203
|
+
logger.progress &@logger
|
204
|
+
|
205
|
+
@server = @loop.tcp
|
206
|
+
@client = @loop.tcp
|
207
|
+
|
208
|
+
@server.bind('127.0.0.1', 34568) do |server|
|
209
|
+
server.accept do |client|
|
210
|
+
client.progress do |data|
|
211
|
+
file = @loop.file('.rspec', File::RDONLY)
|
212
|
+
file.progress do
|
213
|
+
file.send_file(client, :http).then(proc {
|
214
|
+
file.close
|
215
|
+
client.close
|
216
|
+
}, proc { |error|
|
217
|
+
@general_failure << error
|
218
|
+
})
|
219
|
+
end
|
220
|
+
file.catch do |error|
|
221
|
+
@general_failure << error.inspect
|
222
|
+
file.close
|
223
|
+
client.close
|
224
|
+
end
|
225
|
+
end
|
226
|
+
client.start_read
|
227
|
+
client.finally do
|
228
|
+
@timeout.close
|
229
|
+
@server.close
|
230
|
+
@loop.stop
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
# catch errors
|
235
|
+
@server.catch do |reason|
|
236
|
+
@general_failure << reason.inspect
|
237
|
+
@loop.stop
|
238
|
+
end
|
239
|
+
# start listening
|
240
|
+
@server.listen(5)
|
241
|
+
|
242
|
+
|
243
|
+
# connect client to server
|
244
|
+
@client.connect('127.0.0.1', 34568) do |client|
|
245
|
+
client.progress do |data|
|
246
|
+
@log << data
|
247
|
+
end
|
248
|
+
|
249
|
+
@client.start_read
|
250
|
+
@client.write('send file')
|
251
|
+
end
|
252
|
+
# catch errors
|
253
|
+
@client.catch do |reason|
|
254
|
+
@general_failure << reason.inspect
|
255
|
+
@server.close
|
256
|
+
@loop.stop
|
257
|
+
end
|
258
|
+
}
|
259
|
+
|
260
|
+
expect(@general_failure).to eq([])
|
261
|
+
|
262
|
+
# Windows GIT adds the carriage return
|
263
|
+
if FFI::Platform.windows?
|
264
|
+
expect(@log.join('')).to eq("13\r\n--format progress\r\n\r\n0\r\n\r\n")
|
265
|
+
else
|
266
|
+
expect(@log.join('')).to eq("12\r\n--format progress\n\r\n0\r\n\r\n")
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|