brew/Library/Homebrew/test/cmd/deps_spec.rb

46 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2024-03-29 18:09:51 -07:00
require "cmd/deps"
2020-05-04 12:59:56 +01:00
require "cmd/shared_examples/args_parse"
2024-03-29 18:09:51 -07:00
RSpec.describe Homebrew::Cmd::Deps do
2024-03-30 19:10:56 -07:00
include FileUtils
2020-05-04 12:59:56 +01:00
it_behaves_like "parseable arguments"
it "outputs all of a Formula's dependencies and their dependencies on separate lines", :integration_test, :no_api do
# Included in output
2017-02-21 20:14:21 -05:00
setup_test_formula "bar"
setup_test_formula "foo"
setup_test_formula "test"
# Excluded from output
2018-07-11 15:17:40 +02:00
setup_test_formula "baz", <<~RUBY
url "https://brew.sh/baz-1.0"
2017-02-21 20:14:21 -05:00
depends_on "bar"
depends_on "build" => :build
depends_on "test" => :test
depends_on "optional" => :optional
depends_on "recommended_test" => [:recommended, :test]
depends_on "installed"
2018-07-11 15:17:40 +02:00
RUBY
setup_test_formula "build"
setup_test_formula "optional"
setup_test_formula "recommended_test"
setup_test_formula "installed"
# Mock `Formula#any_version_installed?` by creating the tab in a plausible keg directory and opt link
keg_dir = HOMEBREW_CELLAR/"installed/1.0"
keg_dir.mkpath
2024-06-25 00:15:41 -04:00
touch keg_dir/AbstractTab::FILENAME
opt_link = HOMEBREW_PREFIX/"opt/installed"
opt_link.parent.mkpath
FileUtils.ln_sf keg_dir, opt_link
2017-02-23 01:54:44 -05:00
expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
2017-02-24 17:21:50 -05:00
.to be_a_success
.and output("bar\nfoo\ntest\n").to_stdout
.and output(/not the actual runtime dependencies/).to_stderr
2017-02-21 20:14:21 -05:00
end
end