77 lines
2.6 KiB
Ruby
77 lines
2.6 KiB
Ruby
class Xxh < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Bring your favorite shell wherever you go through the ssh"
|
|
homepage "https://github.com/xxh/xxh"
|
|
url "https://files.pythonhosted.org/packages/c6/fb/76429ae5970e334996276075338533043bfbef6f96d7e9340ef433662834/xxh-xxh-0.8.3.tar.gz"
|
|
sha256 "2ba8bbb5d75c77095580b3f2f5570b1700834a42f50e1caaf50a97de925d51bf"
|
|
license "BSD-2-Clause"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "34a321ac28c031fdb427f866d04a3e5d8aa074e2050afb330edc1718147fa3d9" => :catalina
|
|
sha256 "525eb4703597ec79fcc04f52058b0df50151ce375a72186e8b062fefc955e20f" => :mojave
|
|
sha256 "029ad00049f267959b390fda46ce1889a0fc7c3d3fdea68844ce477e2cb86e91" => :high_sierra
|
|
end
|
|
|
|
depends_on "python@3.8"
|
|
|
|
resource "pexpect" do
|
|
url "https://files.pythonhosted.org/packages/e5/9b/ff402e0e930e70467a7178abb7c128709a30dfb22d8777c043e501bc1b10/pexpect-4.8.0.tar.gz"
|
|
sha256 "fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"
|
|
end
|
|
|
|
resource "ptyprocess" do
|
|
url "https://files.pythonhosted.org/packages/7d/2d/e4b8733cf79b7309d84c9081a4ab558c89d8c89da5961bf4ddb050ca1ce0/ptyprocess-0.6.0.tar.gz"
|
|
sha256 "923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0"
|
|
end
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
|
|
sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
|
|
end
|
|
|
|
def install
|
|
virtualenv_install_with_resources
|
|
end
|
|
|
|
test do
|
|
assert_match version.to_s, shell_output("#{bin}/xxh --version")
|
|
|
|
(testpath/"config.xxhc").write <<~EOS
|
|
hosts:
|
|
test.localhost:
|
|
-o: HostName=127.0.0.1
|
|
+s: xxh-shell-zsh
|
|
EOS
|
|
begin
|
|
port = free_port
|
|
server = TCPServer.new(port)
|
|
server_pid = fork do
|
|
msg = server.accept.gets
|
|
server.close
|
|
assert_match "SSH", msg
|
|
end
|
|
|
|
stdout, stderr, = Open3.capture3(
|
|
"#{bin}/xxh", "test.localhost",
|
|
"-p", port.to_s,
|
|
"+xc", "#{testpath}/config.xxhc",
|
|
"+v"
|
|
)
|
|
|
|
argv = stdout.lines.grep(/^Final arguments list:/).first.split(":").second
|
|
args = JSON.parse argv.tr("'", "\"")
|
|
assert_include args, "xxh-shell-zsh"
|
|
|
|
ssh_argv = stderr.lines.grep(/^ssh arguments:/).first.split(":").second
|
|
ssh_args = JSON.parse ssh_argv.tr("'", "\"")
|
|
assert_include ssh_args, "Port=#{port}"
|
|
assert_include ssh_args, "HostName=127.0.0.1"
|
|
assert_match "Connection closed by remote host", stderr
|
|
ensure
|
|
Process.kill("TERM", server_pid)
|
|
end
|
|
end
|
|
end
|