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/ad/7f/effcf114577d392f270831ab36e5833d071ebf1f494dd5acb7cf3953f5fd/xxh-xxh-0.8.4.tar.gz" sha256 "cf6cd0a55bb8befc09b701cf3df226d1e837758bf95110f335359355b4deb96e" license "BSD-2-Clause" livecheck do url :stable end bottle do cellar :any_skip_relocation sha256 "2363936330ef4377578a60a1735fe1740c4849cba53f0b698b3c7247b09d470a" => :catalina sha256 "ac8f21bed8844e190488e83d76f08a350c8efb7b724d3f55c9bca47ddd975e03" => :mojave sha256 "23398378567de59e4a45b37d394467c7980b9db12f3c83ea63ff8da1c0f44c50" => :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