2019-04-19 15:38:03 +09:00
|
|
|
# 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"
|
|
|
|
|
2025-06-10 14:37:21 +00:00
|
|
|
it "outputs all of a Formula's dependencies and their dependencies on separate lines", :integration_test, :no_api do
|
2023-08-27 17:03:02 -07:00
|
|
|
# Included in output
|
2017-02-21 20:14:21 -05:00
|
|
|
setup_test_formula "bar"
|
2023-08-27 17:03:02 -07:00
|
|
|
setup_test_formula "foo"
|
|
|
|
setup_test_formula "test"
|
|
|
|
|
|
|
|
# Excluded from output
|
2018-07-11 15:17:40 +02:00
|
|
|
setup_test_formula "baz", <<~RUBY
|
2018-11-28 20:51:55 +01:00
|
|
|
url "https://brew.sh/baz-1.0"
|
2017-02-21 20:14:21 -05:00
|
|
|
depends_on "bar"
|
2023-08-27 17:03:02 -07:00
|
|
|
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
|
2023-08-27 17:03:02 -07:00
|
|
|
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
|
|
|
|
keg_dir = HOMEBREW_CELLAR/"installed"/"1.0"
|
|
|
|
keg_dir.mkpath
|
2024-06-25 00:15:41 -04:00
|
|
|
touch keg_dir/AbstractTab::FILENAME
|
2017-02-23 01:54:44 -05:00
|
|
|
|
2023-08-27 17:03:02 -07:00
|
|
|
expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
|
2017-02-24 17:21:50 -05:00
|
|
|
.to be_a_success
|
2023-08-27 17:03:02 -07:00
|
|
|
.and output("bar\nfoo\ntest\n").to_stdout
|
2025-06-10 15:55:39 +01:00
|
|
|
.and output(/not the actual runtime dependencies/).to_stderr
|
2017-02-21 20:14:21 -05:00
|
|
|
end
|
|
|
|
end
|