81 lines
2.6 KiB
Ruby
81 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/f9/1a/eed7b7bfe434a5db80bd3d3f38c4fa43af0ba0f1b7125e1b369aa9130721/xxh-xxh-0.8.5.tar.gz"
|
|
sha256 "19cab133a5ccd15dc84adcebcaaada66275028f9c649eb57b7cee2cf013f5440"
|
|
license "BSD-2-Clause"
|
|
|
|
livecheck do
|
|
url :stable
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "38aa5b005f8a9c85093fec703ed5e8aeca30a4047424ddb828528dac12301d03" => :catalina
|
|
sha256 "a3e7ca6207304577b2c30d0b77c08905cccdee2833f9251013ab997948c74ca8" => :mojave
|
|
sha256 "2d3575fd4c91dc612d4463c6b359aeae566b6c294866e75716a74becae130980" => :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
|