jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / c / cargo-run-bin.rb
blobbe3358b441ed9175cf6becef2002042f3f035a6b
1 class CargoRunBin < Formula
2   desc "Build, cache, and run binaries from Cargo.toml to avoid global installs"
3   homepage "https://github.com/dustinblackman/cargo-run-bin"
4   url "https://github.com/dustinblackman/cargo-run-bin/archive/refs/tags/v1.7.4.tar.gz"
5   sha256 "fd492430a60ca488ad8c356f9c6389426f3fbcd59658e5b721855e171cb62841"
6   license "MIT"
8   bottle do
9     sha256 cellar: :any_skip_relocation, arm64_sequoia: "e7c12e5d94ffbe160210e9acfb61d1d01363fdf40650bd738a9529417aeb3e39"
10     sha256 cellar: :any_skip_relocation, arm64_sonoma:  "baace800a845a4478368f4f44438fb55be90b595850584b8ba0333c01774cec8"
11     sha256 cellar: :any_skip_relocation, arm64_ventura: "18b37befe574ec3716f12943da256fb7b0c066dedacc9f45ec985a7c42bb3678"
12     sha256 cellar: :any_skip_relocation, sonoma:        "52873150520a420f132bc02acf2a488597eb4957107a55da37633a26a7142d59"
13     sha256 cellar: :any_skip_relocation, ventura:       "eae3e5a1faff8be5f6606211dc3fb2f38d6d0930f0dff73559667448d3decd36"
14     sha256 cellar: :any_skip_relocation, x86_64_linux:  "df0cd8b3c3dac21a4430ac243db6f937aa3765efa7855dce3918cbd4f2421c13"
15   end
17   depends_on "rust" => :build
18   depends_on "rustup" => :test
20   def install
21     system "cargo", "install", *std_cargo_args
22   end
24   test do
25     assert_equal "cargo-run-bin #{version}", shell_output("#{bin}/cargo-bin -V").strip
27     # Show that we can use a different toolchain than the one provided by the `rust` formula.
28     # https://github.com/Homebrew/homebrew-core/pull/134074#pullrequestreview-1484979359
29     ENV.prepend_path "PATH", Formula["rustup"].bin
30     system "rustup", "default", "beta"
31     system "rustup", "set", "profile", "minimal"
33     (testpath/"Cargo.toml").write <<~TOML
34       [package]
35       name = "homebrew_test"
36       version = "0.1.0"
37       edition = "2021"
39       [[bin]]
40       name = "homebrew_test"
41       path = "src/main.rs"
43       [package.metadata.bin]
44       cargo-nextest = { version = "0.9.57", locked = true }
45     TOML
47     (testpath/"src/main.rs").write <<~RUST
48       fn main() {
49           println!("Hello, world!");
50       }
51     RUST
53     system "cargo", "build"
54     system bin/"cargo-bin", "--install"
55     system bin/"cargo-bin", "--sync-aliases"
57     assert_match <<~TOML, File.read(testpath/".cargo/config.toml")
58       [alias]
59       nextest = ["bin", "cargo-nextest"]
60     TOML
62     assert_match "next-generation test runner", shell_output("cargo nextest --help")
63   end
64 end