Skip to content

Commit

Permalink
MT: workaround regular timeouts in HTTP::Server specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Dec 14, 2023
1 parent 0b251d4 commit 05522e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions spec/std/http/server/server_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ describe HTTP::Server do
server = HTTP::Server.new { }
server.bind_unused_port

spawn do
run_server(server) do
server.close
sleep 0.001
end

server.listen
end

it "closes the server" do
Expand Down
5 changes: 5 additions & 0 deletions spec/std/http/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def run_server(server, &)
wait_for { server.listening? }
wait_until_blocked f

{% if flag?(:preview_mt) %}
# avoids fiber synchronization issues in specs, like closing the server
# before we properly listen, ...
sleep 0.001
{% end %}
yield server_done
ensure
server.close unless server.closed?
Expand Down

0 comments on commit 05522e4

Please sign in to comment.