corkscrew: add test
Closes Homebrew/homebrew#42610. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
3d39c691d0
commit
bc9de40f0e
1 changed files with 23 additions and 0 deletions
|
@ -13,4 +13,27 @@ class Corkscrew < Formula
|
|||
"--prefix=#{prefix}"
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
require "open3"
|
||||
require "webrick"
|
||||
require "webrick/httpproxy"
|
||||
|
||||
pid = fork do
|
||||
proxy = WEBrick::HTTPProxyServer.new :Port => 8080
|
||||
proxy.start
|
||||
end
|
||||
|
||||
sleep 1
|
||||
|
||||
begin
|
||||
Open3.popen3("#{bin}/corkscrew 127.0.0.1 8080 www.google.com 80") do |stdin, stdout, _|
|
||||
stdin.write "GET /index.html HTTP/1.1\r\n\r\n"
|
||||
assert_match "HTTP/1.1", stdout.gets("\r\n\r\n")
|
||||
end
|
||||
ensure
|
||||
Process.kill 9, pid
|
||||
Process.wait pid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue