From 29622c35d145dc82984282cf110596555a39f000 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Tue, 7 Jul 2020 21:02:06 +0800 Subject: [PATCH] tests: wrote up more tests for brew install --- Library/Homebrew/test/cmd/install_spec.rb | 20 +++++++++++++++++++ .../spec/shared_context/integration_test.rb | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index 70ba941c78..b6955930ce 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -17,6 +17,26 @@ describe "brew install", :integration_test do expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").not_to be_a_file end + it "does not install formulae with forbidden license" do + setup_test_formula "package_license" + + expect { brew "install", "package_license", "HOMEBREW_FORBIDDEN_LICENSES" => "0BSD MIT"} + .to output("Error: package_license has a forbidden license 0BSD.\n").to_stderr + .and not_to_output.to_stdout + .and be_a_failure + expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").not_to be_a_file + end + + it "installs formulae if formulae license is not forbidden" do + setup_test_formula "testball1" + + expect { brew "install", "testball1", "HOMEBREW_FORBIDDEN_LICENSES" => "AAK ADSL AML"} + .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout + .and not_to_output.to_stderr + .and be_a_success + expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").not_to be_a_file + end + it "installs formulae with options" do setup_test_formula "testball1" diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 7ecb936ec8..619eae5c80 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -161,6 +161,12 @@ RSpec.shared_context "integration test" do content = <<~RUBY url "https://brew.sh/#{name}-1.0" RUBY + + when "package_license" + content = <<~RUBY + url "https://brew.sh/#patchelf-1.0" + license "0BSD" + RUBY end Formulary.core_path(name).tap do |formula_path|