http-server: make test more robust by using a custom port
This commit is contained in:
parent
bcc4a12c2e
commit
9d2cb41902
1 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue