http-server: make test more robust by using a custom port

This commit is contained in:
Christian Moritz 2019-11-07 13:44:03 +01:00 committed by FX Coudert
parent bcc4a12c2e
commit 9d2cb41902

View file

@ -24,11 +24,15 @@ class HttpServer < Formula
end
test do
server = TCPServer.new(0)
port = server.addr[1]
server.close
pid = fork do
exec "#{bin}/http-server"
exec "#{bin}/http-server", "-p#{port}"
end
sleep 1
output = shell_output("curl -sI http://localhost:8080")
output = shell_output("curl -sI http://localhost:#{port}")
assert_match /200 OK/m, output
ensure
Process.kill("HUP", pid)