homebrew-core/Formula/rust-analyzer.rb

74 lines
1.6 KiB
Ruby

class RustAnalyzer < Formula
desc "Experimental Rust compiler front-end for IDEs"
homepage "https://rust-analyzer.github.io/"
url "https://github.com/rust-analyzer/rust-analyzer.git",
tag: "2020-11-02",
revision: "86d3b784075966028c84e24ff4327a26fe7fbacb"
version "2020-11-02"
license "Apache-2.0"
bottle do
cellar :any_skip_relocation
sha256 "2881a977afb1077960697ac06fcca13190bde9d547f372f866e34fd16991b3f3" => :catalina
sha256 "b38e20d947648e5a81db4e44edc95181dadbbacc723dbce46ef0c32a8b72ba42" => :mojave
sha256 "650c1fd27668058147b0b0b2e0850db4cc581371d68ce2f90ed1d746b6449c82" => :high_sierra
end
depends_on "rust" => :build
def install
cd "crates/rust-analyzer" do
system "cargo", "install", "--bin", "rust-analyzer", *std_cargo_args
end
end
test do
def rpc(json)
"Content-Length: #{json.size}\r\n" \
"\r\n" \
"#{json}"
end
input = rpc <<-EOF
{
"jsonrpc":"2.0",
"id":1,
"method":"initialize",
"params": {
"rootUri": "file:/dev/null",
"capabilities": {}
}
}
EOF
input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"initialized",
"params": {}
}
EOF
input += rpc <<-EOF
{
"jsonrpc":"2.0",
"id": 1,
"method":"shutdown",
"params": null
}
EOF
input += rpc <<-EOF
{
"jsonrpc":"2.0",
"method":"exit",
"params": {}
}
EOF
output = /Content-Length: \d+\r\n\r\n/
assert_match output, pipe_output("#{bin}/rust-analyzer", input, 0)
end
end