mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
tests: default to API mode enabled.
While we're here, also add `brew tests --no-parallel` which I relied on during testing. Pretty much anywhere we rely on a stubbed formula on disk to work: we need to disable the API.
This commit is contained in:
parent
3c9a7332d4
commit
e9f55a8f71
@ -28,6 +28,8 @@ module Homebrew
|
|||||||
description: "Only runs tests on files that were changed from the master branch."
|
description: "Only runs tests on files that were changed from the master branch."
|
||||||
switch "--fail-fast",
|
switch "--fail-fast",
|
||||||
description: "Exit early on the first failing test."
|
description: "Exit early on the first failing test."
|
||||||
|
switch "--no-parallel",
|
||||||
|
description: "Run tests serially."
|
||||||
flag "--only=",
|
flag "--only=",
|
||||||
description: "Run only `<test_script>_spec.rb`. Appending `:<line_number>` will start at a " \
|
description: "Run only `<test_script>_spec.rb`. Appending `:<line_number>` will start at a " \
|
||||||
"specific line."
|
"specific line."
|
||||||
@ -49,7 +51,7 @@ module Homebrew
|
|||||||
HOMEBREW_LIBRARY_PATH.cd do
|
HOMEBREW_LIBRARY_PATH.cd do
|
||||||
setup_environment!
|
setup_environment!
|
||||||
|
|
||||||
parallel = true
|
parallel = !args.no_parallel?
|
||||||
|
|
||||||
only = args.only
|
only = args.only
|
||||||
files = if only
|
files = if only
|
||||||
@ -240,9 +242,6 @@ module Homebrew
|
|||||||
ENV["HOMEBREW_SORBET_RUNTIME"] = "1"
|
ENV["HOMEBREW_SORBET_RUNTIME"] = "1"
|
||||||
ENV["HOMEBREW_NO_FORCE_BREW_WRAPPER"] = "1"
|
ENV["HOMEBREW_NO_FORCE_BREW_WRAPPER"] = "1"
|
||||||
|
|
||||||
# TODO: remove this and fix tests when possible.
|
|
||||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
|
||||||
|
|
||||||
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
||||||
|
|
||||||
# Avoid local configuration messing with tests, e.g. git being configured
|
# Avoid local configuration messing with tests, e.g. git being configured
|
||||||
|
@ -520,6 +520,7 @@ class FormulaInstaller
|
|||||||
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
|
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
|
||||||
|
|
||||||
if (tap = formula.tap) && tap.should_report_analytics?
|
if (tap = formula.tap) && tap.should_report_analytics?
|
||||||
|
require "utils/analytics"
|
||||||
Utils::Analytics.report_package_event(:formula_install, package_name: formula.name, tap_name: tap.name,
|
Utils::Analytics.report_package_event(:formula_install, package_name: formula.name, tap_name: tap.name,
|
||||||
on_request: installed_on_request?, options:)
|
on_request: installed_on_request?, options:)
|
||||||
end
|
end
|
||||||
|
@ -23,6 +23,9 @@ class Homebrew::DevCmd::Tests::Args < Homebrew::CLI::Args
|
|||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def generic?; end
|
def generic?; end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def no_parallel?; end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def online?; end
|
def online?; end
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ RSpec.describe Homebrew::API::Cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
allow(Homebrew::API).to receive(:fetch_json_api_file).and_return([[], true])
|
||||||
allow_any_instance_of(Homebrew::API::Download).to receive(:fetch)
|
allow_any_instance_of(Homebrew::API::Download).to receive(:fetch)
|
||||||
allow_any_instance_of(Homebrew::API::Download).to receive(:symlink_location).and_return(
|
allow_any_instance_of(Homebrew::API::Download).to receive(:symlink_location).and_return(
|
||||||
TEST_FIXTURE_DIR/"cask/Casks/everything.rb",
|
TEST_FIXTURE_DIR/"cask/Casks/everything.rb",
|
||||||
|
@ -12,7 +12,7 @@ require "bundle/mac_app_store_installer"
|
|||||||
require "bundle/dsl"
|
require "bundle/dsl"
|
||||||
require "bundle/skipper"
|
require "bundle/skipper"
|
||||||
|
|
||||||
RSpec.describe Homebrew::Bundle::Commands::Check do
|
RSpec.describe Homebrew::Bundle::Commands::Check, :no_api do
|
||||||
let(:do_check) do
|
let(:do_check) do
|
||||||
described_class.run(no_upgrade:, verbose:)
|
described_class.run(no_upgrade:, verbose:)
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ require "bundle"
|
|||||||
require "bundle/commands/cleanup"
|
require "bundle/commands/cleanup"
|
||||||
|
|
||||||
RSpec.describe Homebrew::Bundle::Commands::Cleanup do
|
RSpec.describe Homebrew::Bundle::Commands::Cleanup do
|
||||||
describe "read Brewfile and current installation" do
|
describe "read Brewfile and current installation", :no_api do
|
||||||
before do
|
before do
|
||||||
described_class.reset!
|
described_class.reset!
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ RSpec.describe Homebrew::Bundle::Commands::Exec do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a Brewfile is found" do
|
context "when a Brewfile is found", :no_api do
|
||||||
let(:brewfile_contents) { "brew 'openssl'" }
|
let(:brewfile_contents) { "brew 'openssl'" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -16,7 +16,7 @@ RSpec.describe Homebrew::Bundle::Commands::Install do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a Brewfile is found" do
|
context "when a Brewfile is found", :no_api do
|
||||||
let(:brewfile_contents) do
|
let(:brewfile_contents) do
|
||||||
<<~EOS
|
<<~EOS
|
||||||
tap 'phinze/cask'
|
tap 'phinze/cask'
|
||||||
|
@ -31,10 +31,6 @@ RSpec.describe Cask::CaskLoader::FromAPILoader, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when using the API" do
|
context "when using the API" do
|
||||||
before do
|
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a loader for valid token" do
|
it "returns a loader for valid token" do
|
||||||
expect(described_class.try_new(api_token))
|
expect(described_class.try_new(api_token))
|
||||||
.to be_a(described_class)
|
.to be_a(described_class)
|
||||||
|
@ -45,10 +45,6 @@ RSpec.describe Cask::CaskLoader, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when using the API" do
|
context "when using the API" do
|
||||||
before do
|
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "warns when using the short token" do
|
it "warns when using the short token" do
|
||||||
expect do
|
expect do
|
||||||
expect(described_class.for("version-newest")).to be_a Cask::CaskLoader::FromAPILoader
|
expect(described_class.for("version-newest")).to be_a Cask::CaskLoader::FromAPILoader
|
||||||
|
@ -46,13 +46,13 @@ RSpec.describe Cask::Cask, :cask do
|
|||||||
expect(c.token).to eq("caffeine")
|
expect(c.token).to eq("caffeine")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an instance of the Cask from a URL", :needs_utils_curl, :no_api do
|
it "returns an instance of the Cask from a URL", :needs_utils_curl do
|
||||||
c = Cask::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb")
|
c = Cask::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb")
|
||||||
expect(c).to be_a(described_class)
|
expect(c).to be_a(described_class)
|
||||||
expect(c.token).to eq("local-caffeine")
|
expect(c.token).to eq("local-caffeine")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error when failing to download a Cask from a URL", :needs_utils_curl, :no_api do
|
it "raises an error when failing to download a Cask from a URL", :needs_utils_curl do
|
||||||
expect do
|
expect do
|
||||||
Cask::CaskLoader.load("file://#{tap_path}/Casks/notacask.rb")
|
Cask::CaskLoader.load("file://#{tap_path}/Casks/notacask.rb")
|
||||||
end.to raise_error(Cask::CaskUnavailableError)
|
end.to raise_error(Cask::CaskUnavailableError)
|
||||||
|
@ -30,7 +30,7 @@ RSpec.describe CaskDependent, :needs_macos do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#recursive_dependencies", :integration_test do
|
describe "#recursive_dependencies", :integration_test, :no_api do
|
||||||
it "is all the dependencies of the cask" do
|
it "is all the dependencies of the cask" do
|
||||||
setup_test_formula "foo"
|
setup_test_formula "foo"
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
|
@ -8,7 +8,7 @@ RSpec.describe Homebrew::Cmd::Deps do
|
|||||||
|
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "outputs all of a Formula's dependencies and their dependencies on separate lines", :integration_test do
|
it "outputs all of a Formula's dependencies and their dependencies on separate lines", :integration_test, :no_api do
|
||||||
# Included in output
|
# Included in output
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
setup_test_formula "foo"
|
setup_test_formula "foo"
|
||||||
|
@ -15,7 +15,7 @@ RSpec.describe Homebrew::Cmd::Desc do
|
|||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "errors when searching without --eval-all", :integration_test do
|
it "errors when searching without --eval-all", :integration_test, :no_api do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
expect { brew "desc", "--search", "testball" }
|
expect { brew "desc", "--search", "testball" }
|
||||||
@ -23,7 +23,7 @@ RSpec.describe Homebrew::Cmd::Desc do
|
|||||||
.and be_a_failure
|
.and be_a_failure
|
||||||
end
|
end
|
||||||
|
|
||||||
it "successfully searches with --search --eval-all", :integration_test do
|
it "successfully searches with --search --eval-all", :integration_test, :no_api do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
expect { brew "desc", "--search", "--eval-all", "ball" }
|
expect { brew "desc", "--search", "--eval-all", "ball" }
|
||||||
@ -34,7 +34,6 @@ RSpec.describe Homebrew::Cmd::Desc do
|
|||||||
it "successfully searches without --eval-all, with API", :integration_test, :needs_network do
|
it "successfully searches without --eval-all, with API", :integration_test, :needs_network do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
expect { brew "desc", "--search", "testball", "HOMEBREW_NO_INSTALL_FROM_API" => nil }
|
expect { brew "desc", "--search", "testball" }.to be_a_success
|
||||||
.to be_a_success
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ RSpec.describe Homebrew::Cmd::Leaves do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are installed Formulae", :integration_test do
|
context "when there are installed Formulae", :integration_test, :no_api do
|
||||||
it "prints all installed Formulae that are not dependencies of another installed Formula" do
|
it "prints all installed Formulae that are not dependencies of another installed Formula" do
|
||||||
setup_test_formula "foo"
|
setup_test_formula "foo"
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
|
@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse"
|
|||||||
RSpec.describe Homebrew::Cmd::Migrate do
|
RSpec.describe Homebrew::Cmd::Migrate do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "migrates a renamed Formula", :integration_test do
|
it "migrates a renamed Formula", :integration_test, :no_api do
|
||||||
setup_test_formula "testball1"
|
setup_test_formula "testball1"
|
||||||
setup_test_formula "testball2"
|
setup_test_formula "testball2"
|
||||||
install_and_rename_coretap_formula "testball1", "testball2"
|
install_and_rename_coretap_formula "testball1", "testball2"
|
||||||
|
@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse"
|
|||||||
RSpec.describe Homebrew::Cmd::Missing do
|
RSpec.describe Homebrew::Cmd::Missing do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "prints missing dependencies", :integration_test do
|
it "prints missing dependencies", :integration_test, :no_api do
|
||||||
setup_test_formula "foo"
|
setup_test_formula "foo"
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse"
|
|||||||
RSpec.describe Homebrew::Cmd::SearchCmd do
|
RSpec.describe Homebrew::Cmd::SearchCmd do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "finds formula in search", :integration_test do
|
it "finds formula in search", :integration_test, :no_api do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
|
||||||
expect { brew "search", "testball" }
|
expect { brew "search", "testball" }
|
||||||
|
@ -16,7 +16,7 @@ RSpec.describe Homebrew::Cmd::TapInfo do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "display brief statistics for all installed taps", :integration_test, :needs_network do
|
it "display brief statistics for all installed taps", :integration_test, :needs_network do
|
||||||
expect { brew "tap-info", "HOMEBREW_NO_INSTALL_FROM_API" => nil }
|
expect { brew "tap-info" }
|
||||||
.to output(/\d+ taps?, \d+ private/).to_stdout
|
.to output(/\d+ taps?, \d+ private/).to_stdout
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
|
@ -18,7 +18,7 @@ RSpec.describe Homebrew::Cmd::Untap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#installed_formulae_for", :integration_test do
|
describe "#installed_formulae_for", :integration_test do
|
||||||
shared_examples "finds installed formulae in tap" do
|
shared_examples "finds installed formulae in tap", :no_api do
|
||||||
def load_formula(name:, with_formula_file: false, mock_install: false)
|
def load_formula(name:, with_formula_file: false, mock_install: false)
|
||||||
formula = if with_formula_file
|
formula = if with_formula_file
|
||||||
path = setup_test_formula(name, tap:)
|
path = setup_test_formula(name, tap:)
|
||||||
@ -84,7 +84,7 @@ RSpec.describe Homebrew::Cmd::Untap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#installed_casks_for", :cask do
|
describe "#installed_casks_for", :cask do
|
||||||
shared_examples "finds installed casks in tap" do
|
shared_examples "finds installed casks in tap", :no_api do
|
||||||
def load_cask(token:, with_cask_file: false, mock_install: false)
|
def load_cask(token:, with_cask_file: false, mock_install: false)
|
||||||
cask_loader = Cask::CaskLoader::FromContentLoader.new(<<~RUBY, tap:)
|
cask_loader = Cask::CaskLoader::FromContentLoader.new(<<~RUBY, tap:)
|
||||||
cask '#{token}' do
|
cask '#{token}' do
|
||||||
|
@ -10,7 +10,7 @@ RSpec.describe Homebrew::Cmd::Uses do
|
|||||||
|
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "prints the Formulae a given Formula is used by", :integration_test do
|
it "prints the Formulae a given Formula is used by", :integration_test, :no_api do
|
||||||
# Included in output
|
# Included in output
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
setup_test_formula "optional", <<~RUBY
|
setup_test_formula "optional", <<~RUBY
|
||||||
@ -46,7 +46,7 @@ RSpec.describe Homebrew::Cmd::Uses do
|
|||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles unavailable formula", :integration_test do
|
it "handles unavailable formula", :integration_test, :no_api do
|
||||||
setup_test_formula "foo"
|
setup_test_formula "foo"
|
||||||
setup_test_formula "bar"
|
setup_test_formula "bar"
|
||||||
setup_test_formula "optional", <<~RUBY
|
setup_test_formula "optional", <<~RUBY
|
||||||
|
@ -23,7 +23,7 @@ RSpec.describe CompilerSelector do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#compiler" do
|
describe "#compiler", :no_api do
|
||||||
it "defaults to cc" do
|
it "defaults to cc" do
|
||||||
expect(selector.compiler).to eq(cc)
|
expect(selector.compiler).to eq(cc)
|
||||||
end
|
end
|
||||||
|
@ -117,7 +117,6 @@ RSpec.describe Homebrew::Diagnostic::Checks do
|
|||||||
|
|
||||||
specify "#check_for_unnecessary_core_tap" do
|
specify "#check_for_unnecessary_core_tap" do
|
||||||
ENV.delete("HOMEBREW_DEVELOPER")
|
ENV.delete("HOMEBREW_DEVELOPER")
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
|
|
||||||
expect_any_instance_of(CoreTap).to receive(:installed?).and_return(true)
|
expect_any_instance_of(CoreTap).to receive(:installed?).and_return(true)
|
||||||
|
|
||||||
@ -126,7 +125,6 @@ RSpec.describe Homebrew::Diagnostic::Checks do
|
|||||||
|
|
||||||
specify "#check_for_unnecessary_cask_tap" do
|
specify "#check_for_unnecessary_cask_tap" do
|
||||||
ENV.delete("HOMEBREW_DEVELOPER")
|
ENV.delete("HOMEBREW_DEVELOPER")
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
|
|
||||||
expect_any_instance_of(CoreCaskTap).to receive(:installed?).and_return(true)
|
expect_any_instance_of(CoreCaskTap).to receive(:installed?).and_return(true)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ RSpec.describe "Exception" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "without a dependent" do
|
context "without a dependent" do
|
||||||
it(:to_s) { expect(error.to_s).to eq('No available formula with the name "foo".') }
|
it(:to_s) { expect(error.to_s).to match(/^No available formula with the name "foo"\./) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a dependent" do
|
context "with a dependent" do
|
||||||
@ -80,7 +80,7 @@ RSpec.describe "Exception" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it(:to_s) do
|
it(:to_s) do
|
||||||
expect(error.to_s).to eq('No available formula with the name "foo" (dependency of foobar).')
|
expect(error.to_s).to match(/^No available formula with the name "foo" \(dependency of foobar\)\./)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1261,7 +1261,7 @@ RSpec.describe Homebrew::FormulaAuditor do
|
|||||||
allow(File).to receive(:open).and_return("")
|
allow(File).to receive(:open).and_return("")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "it warns when conflicting with non-existing formula" do
|
specify "it warns when conflicting with non-existing formula", :no_api do
|
||||||
foo = formula("foo") do
|
foo = formula("foo") do
|
||||||
url "https://brew.sh/bar-1.0.tgz"
|
url "https://brew.sh/bar-1.0.tgz"
|
||||||
|
|
||||||
@ -1275,7 +1275,7 @@ RSpec.describe Homebrew::FormulaAuditor do
|
|||||||
.to match("Can't find conflicting formula \"bar\"")
|
.to match("Can't find conflicting formula \"bar\"")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "it warns when conflicting with itself" do
|
specify "it warns when conflicting with itself", :no_api do
|
||||||
foo = formula("foo") do
|
foo = formula("foo") do
|
||||||
url "https://brew.sh/bar-1.0.tgz"
|
url "https://brew.sh/bar-1.0.tgz"
|
||||||
|
|
||||||
@ -1290,7 +1290,7 @@ RSpec.describe Homebrew::FormulaAuditor do
|
|||||||
.to match("Formula should not conflict with itself")
|
.to match("Formula should not conflict with itself")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "it warns when another formula does not have a symmetric conflict" do
|
specify "it warns when another formula does not have a symmetric conflict", :no_api do
|
||||||
stub_formula_loader formula("gcc") { url "gcc-1.0" }
|
stub_formula_loader formula("gcc") { url "gcc-1.0" }
|
||||||
stub_formula_loader formula("glibc") { url "glibc-1.0" }
|
stub_formula_loader formula("glibc") { url "glibc-1.0" }
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ RSpec.describe Formulary do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::factory" do
|
describe "::factory" do
|
||||||
context "without the API" do
|
context "without the API", :no_api do
|
||||||
before do
|
before do
|
||||||
formula_path.dirname.mkpath
|
formula_path.dirname.mkpath
|
||||||
formula_path.write formula_content
|
formula_path.write formula_content
|
||||||
@ -129,7 +129,7 @@ RSpec.describe Formulary do
|
|||||||
end.to raise_error(FormulaUnavailableError)
|
end.to raise_error(FormulaUnavailableError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a Formula when given a URL", :needs_utils_curl, :no_api do
|
it "returns a Formula when given a URL", :needs_utils_curl do
|
||||||
formula = described_class.factory("file://#{formula_path}")
|
formula = described_class.factory("file://#{formula_path}")
|
||||||
expect(formula).to be_a(Formula)
|
expect(formula).to be_a(Formula)
|
||||||
end
|
end
|
||||||
@ -398,8 +398,6 @@ RSpec.describe Formulary do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
|
|
||||||
# avoid unnecessary network calls
|
# avoid unnecessary network calls
|
||||||
allow(Homebrew::API::Formula).to receive_messages(all_aliases: {}, all_renames: {})
|
allow(Homebrew::API::Formula).to receive_messages(all_aliases: {}, all_renames: {})
|
||||||
allow(CoreTap.instance).to receive(:tap_migrations).and_return({})
|
allow(CoreTap.instance).to receive(:tap_migrations).and_return({})
|
||||||
@ -645,16 +643,12 @@ RSpec.describe Formulary do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when given a tapped name" do
|
context "when given a tapped name" do
|
||||||
it "returns a `FromTapLoader`" do
|
it "returns a `FromTapLoader`", :no_api do
|
||||||
expect(described_class.loader_for("homebrew/core/gcc")).to be_a Formulary::FromTapLoader
|
expect(described_class.loader_for("homebrew/core/gcc")).to be_a Formulary::FromTapLoader
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when not using the API" do
|
context "when not using the API", :no_api do
|
||||||
before do
|
|
||||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when a formula is migrated" do
|
context "when a formula is migrated" do
|
||||||
let(:token) { "foo" }
|
let(:token) { "foo" }
|
||||||
|
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
require "github_runner_matrix"
|
require "github_runner_matrix"
|
||||||
require "test/support/fixtures/testball"
|
require "test/support/fixtures/testball"
|
||||||
|
|
||||||
RSpec.describe GitHubRunnerMatrix do
|
RSpec.describe GitHubRunnerMatrix, :no_api do
|
||||||
before do
|
before do
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_RUNNER").and_return("ubuntu-latest")
|
allow(ENV).to receive(:fetch).with("HOMEBREW_LINUX_RUNNER").and_return("ubuntu-latest")
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_LONG_TIMEOUT", "false").and_return("false")
|
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_LONG_TIMEOUT", "false").and_return("false")
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false").and_return("false")
|
allow(ENV).to receive(:fetch).with("HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER", "false").and_return("false")
|
||||||
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345")
|
allow(ENV).to receive(:fetch).with("GITHUB_RUN_ID").and_return("12345")
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_NO_INSTALL_FROM_API", nil).and_call_original
|
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_EVAL_ALL", nil).and_call_original
|
allow(ENV).to receive(:fetch).with("HOMEBREW_EVAL_ALL", nil).and_call_original
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_SIMULATE_MACOS_ON_LINUX", nil).and_call_original
|
allow(ENV).to receive(:fetch).with("HOMEBREW_SIMULATE_MACOS_ON_LINUX", nil).and_call_original
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_FORBID_PACKAGES_FROM_PATHS", nil).and_call_original
|
allow(ENV).to receive(:fetch).with("HOMEBREW_FORBID_PACKAGES_FROM_PATHS", nil).and_call_original
|
||||||
allow(ENV).to receive(:fetch).with("HOMEBREW_DEVELOPER", nil).and_call_original
|
allow(ENV).to receive(:fetch).with("HOMEBREW_DEVELOPER", nil).and_call_original
|
||||||
|
allow(ENV).to receive(:fetch).with("HOMEBREW_NO_INSTALL_FROM_API", nil).and_call_original
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:newest_supported_macos) do
|
let(:newest_supported_macos) do
|
||||||
|
@ -59,6 +59,7 @@ TEST_DIRECTORIES = [
|
|||||||
CoreTap.instance.path/"Formula",
|
CoreTap.instance.path/"Formula",
|
||||||
HOMEBREW_CACHE,
|
HOMEBREW_CACHE,
|
||||||
HOMEBREW_CACHE_FORMULA,
|
HOMEBREW_CACHE_FORMULA,
|
||||||
|
HOMEBREW_CACHE/"api",
|
||||||
HOMEBREW_CELLAR,
|
HOMEBREW_CELLAR,
|
||||||
HOMEBREW_LOCKS,
|
HOMEBREW_LOCKS,
|
||||||
HOMEBREW_LOGS,
|
HOMEBREW_LOGS,
|
||||||
@ -249,6 +250,11 @@ RSpec.configure do |config|
|
|||||||
@__stderr = $stderr.clone
|
@__stderr = $stderr.clone
|
||||||
@__stdin = $stdin.clone
|
@__stdin = $stdin.clone
|
||||||
|
|
||||||
|
# Link original API cache files to test cache directory.
|
||||||
|
Pathname("#{ENV.fetch("HOMEBREW_CACHE")}/api").glob("*.json").each do |path|
|
||||||
|
FileUtils.ln path, HOMEBREW_CACHE/"api/#{path.basename}"
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if example.metadata.keys.exclude?(:focus) && !ENV.key?("HOMEBREW_VERBOSE_TESTS")
|
if example.metadata.keys.exclude?(:focus) && !ENV.key?("HOMEBREW_VERBOSE_TESTS")
|
||||||
$stdout.reopen(File::NULL)
|
$stdout.reopen(File::NULL)
|
||||||
|
@ -82,6 +82,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
|||||||
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
|
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
|
||||||
"HOMEBREW_DEV_CMD_RUN" => "true",
|
"HOMEBREW_DEV_CMD_RUN" => "true",
|
||||||
"HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
|
"HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
|
||||||
|
"HOMEBREW_NO_INSTALL_FROM_API" => ENV.fetch("HOMEBREW_NO_INSTALL_FROM_API", nil),
|
||||||
"GEM_HOME" => nil,
|
"GEM_HOME" => nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
|||||||
end
|
end
|
||||||
|
|
||||||
formula_path = Formulary.find_formula_in_tap(name.downcase, tap).tap do |path|
|
formula_path = Formulary.find_formula_in_tap(name.downcase, tap).tap do |path|
|
||||||
|
path.dirname.mkpath
|
||||||
path.write <<~RUBY
|
path.write <<~RUBY
|
||||||
class #{Formulary.class_s(name)} < Formula
|
class #{Formulary.class_s(name)} < Formula
|
||||||
#{content.gsub(/^(?!$)/, " ")}
|
#{content.gsub(/^(?!$)/, " ")}
|
||||||
|
@ -500,7 +500,6 @@ RSpec.describe Tap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "includes the core tap with the api" do
|
it "includes the core tap with the api" do
|
||||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
|
||||||
expect(described_class.to_a).to include(CoreTap.instance)
|
expect(described_class.to_a).to include(CoreTap.instance)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -580,7 +579,7 @@ RSpec.describe Tap do
|
|||||||
let(:cask_tap) { CoreCaskTap.instance }
|
let(:cask_tap) { CoreCaskTap.instance }
|
||||||
let(:core_tap) { CoreTap.instance }
|
let(:core_tap) { CoreTap.instance }
|
||||||
|
|
||||||
it "returns expected renames" do
|
it "returns expected renames", :no_api do
|
||||||
[
|
[
|
||||||
[cask_tap, "gimp", []],
|
[cask_tap, "gimp", []],
|
||||||
[core_tap, "schism-tracker", []],
|
[core_tap, "schism-tracker", []],
|
||||||
@ -744,11 +743,11 @@ RSpec.describe Tap do
|
|||||||
expect(core_tap).to be_a_core_tap
|
expect(core_tap).to be_a_core_tap
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "forbidden operations" do
|
specify "forbidden operations", :no_api do
|
||||||
expect { core_tap.uninstall }.to raise_error(RuntimeError)
|
expect { core_tap.uninstall }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "files" do
|
specify "files", :no_api do
|
||||||
path = HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-core"
|
path = HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-core"
|
||||||
formula_file = core_tap.formula_dir/"foo.rb"
|
formula_file = core_tap.formula_dir/"foo.rb"
|
||||||
core_tap.formula_dir.mkpath
|
core_tap.formula_dir.mkpath
|
||||||
|
Loading…
x
Reference in New Issue
Block a user