Skip to content

Commit

Permalink
Windows / MinGW test failure - fix spec_helper.rb
Browse files Browse the repository at this point in the history
See 'Test failures on Windows (MinGW)' #156

Windows / MinGW tests - update spec & examples

Windows / MinGW - appveyor.yml
  • Loading branch information
MSP-Greg committed Jun 30, 2017
1 parent aa76247 commit f8e468c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
18 changes: 8 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ branches:
environment:
PATH: C:\Ruby%RUBY_VERSION%\DevKit\mingw\bin;C:\Ruby%RUBY_VERSION%\bin;C:\Ruby%RUBY_VERSION%\DevKit\bin;%PATH%
matrix:
- RUBY_VERSION: 23
- RUBY_VERSION: 22

matrix:
allow_failures:
- RUBY_VERSION: 23
- RUBY_VERSION: 22
- RUBY_VERSION: "24-x64"
- RUBY_VERSION: "23-x64"
- RUBY_VERSION: "23"
- RUBY_VERSION: "22"

install:
- SET RAKEOPT=-rdevkit
- ruby -v
- gem -v
- bundle -v
- bundle install

build: off

before_build:
- gem update --system
- ruby -v
- make -v
- bundle -v

test_script:
- echo %PATH%
Expand Down
9 changes: 7 additions & 2 deletions spec/nio/selectables/pipe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@
# will throw EAGAIN if there is too little space to write the string
# TODO: Use FFI to lookup the platform-specific size of PIPE_BUF
str = "JUNK IN THE TUBES" * 10_000
cntr = 0
begin
pipe.write_nonblock str
_, writers = select [], [pipe], [], 0
cntr += 1
t = select [], [pipe], [], 0
rescue Errno::EPIPE
break
end while writers && writers.include?(pipe)
rescue IO::EWOULDBLOCKWaitWritable
skip "windows - can't test due to 'select' not showing correct status"
break
end while t && t[1].include?(pipe) && cntr < 20

pipe
end
Expand Down
13 changes: 6 additions & 7 deletions spec/nio/selectables/ssl_socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
cert.issuer = name
cert.subject = name
cert.not_before = Time.now
cert.not_after = Time.now + (365 * 24 * 60 * 60)
cert.not_after = Time.now + (7 * 24 * 60 * 60)
cert.public_key = ssl_key.public_key

cert.sign(ssl_key, OpenSSL::Digest::SHA1.new)
cert.sign(ssl_key, OpenSSL::Digest::SHA256.new)
end
end

Expand Down Expand Up @@ -111,14 +111,15 @@
ssl_peer.accept
thread.join

cntr = 0
begin
_, writers = select [], [ssl_client], [], 0
count = ssl_client.write_nonblock "X" * 1024
expect(count).not_to eq(0)
cntr += 1
t = select [], [ssl_client], [], 0
rescue IO::WaitReadable, IO::WaitWritable
pending "SSL will report writable but not accept writes"
raise if writers.include? ssl_client
end while writers && writers.include?(ssl_client)
end while t && t[1].include?(ssl_client) && cntr < 30

# I think the kernel might manage to drain its buffer a bit even after
# the socket first goes unwritable. Attempt to sleep past this and then
Expand All @@ -141,8 +142,6 @@
end

let :pair do
pending "figure out why newly created sockets are selecting readable immediately"

server = TCPServer.new(addr, port)
client = TCPSocket.new(addr, port)
peer = server.accept
Expand Down
12 changes: 11 additions & 1 deletion spec/nio/selectables/udp_socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@
end

let :writable_subject do
pending "come up with a writable UDPSocket example"
peer = UDPSocket.new
peer.connect "localhost", udp_port
cntr = 0
begin
peer.send("X" * 1024, 0)
cntr += 1
t = select [], [peer], [], 0
rescue => e
skip "Intermittent UDPSocket :writable_subject Error #{e.class}"
end while t && t[1].include?(peer) && cntr < 5
peer
end

let :unwritable_subject do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def next_available_tcp_port
$current_tcp_port += 1

begin
sock = Timeout.timeout(1) { TCPSocket.new("localhost", $current_tcp_port) }
rescue Errno::ECONNREFUSED
sock = Timeout.timeout(0.5) { TCPSocket.new("localhost", $current_tcp_port) }
rescue Errno::ECONNREFUSED, Timeout::Error
break $current_tcp_port
end

Expand Down
3 changes: 0 additions & 3 deletions spec/support/selectable_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
let(:peer) { pair.last }

it "selects readable when the other end closes" do
# hax: this test is broken for OpenSSL sockets
skip "broken for SSL ;_;" if peer.is_a? OpenSSL::SSL::SSLSocket

monitor = selector.register(stream, :r)
expect(selector.select(0)).to be_nil

Expand Down

0 comments on commit f8e468c

Please sign in to comment.